docs: update FTS docs for JS SDK (#1634)

Signed-off-by: BubbleCal <bubble-cal@outlook.com>
This commit is contained in:
BubbleCal
2024-09-13 20:48:29 +08:00
committed by GitHub
parent c7732585bf
commit bf7d2d6fb0
4 changed files with 39 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
LanceDB provides support for full-text search via Lance (before via [Tantivy](https://github.com/quickwit-oss/tantivy) (Python only)), allowing you to incorporate keyword-based search (based on BM25) in your retrieval solutions.
Currently, the Lance full text search is missing some features that are in the Tantivy full text search. This includes phrase queries, re-ranking, and customizing the tokenizer. Thus, in Python, Tantivy is still the default way to do full text search and many of the instructions below apply just to Tantivy-based indices.
Currently, the Lance full text search is missing some features that are in the Tantivy full text search. This includes query parser and customizing the tokenizer. Thus, in Python, Tantivy is still the default way to do full text search and many of the instructions below apply just to Tantivy-based indices.
## Installation (Only for Tantivy-based FTS)

View File

@@ -68,3 +68,25 @@ currently is also a memory intensive operation.
#### Returns
[`Index`](Index.md)
### fts()
> `static` **fts**(`options`?): [`Index`](Index.md)
Create a full text search index
This index is used to search for text data. The index is created by tokenizing the text
into words and then storing occurrences of these words in a data structure called inverted index
that allows for fast search.
During a search the query is tokenized and the inverted index is used to find the rows that
contain the query words. The rows are then scored based on BM25 and the top scoring rows are
sorted and returned.
#### Parameters
**options?**: `Partial`&lt;[`FtsOptions`](../interfaces/FtsOptions.md)&gt;
#### Returns
[`Index`](Index.md)

View File

@@ -501,16 +501,28 @@ Get the schema of the table.
#### search(query)
> `abstract` **search**(`query`): [`VectorQuery`](VectorQuery.md)
> `abstract` **search**(`query`, `queryType`, `ftsColumns`): [`VectorQuery`](VectorQuery.md)
Create a search query to find the nearest neighbors
of the given query vector
of the given query vector, or the documents
with the highest relevance to the query string.
##### Parameters
• **query**: `string`
the query. This will be converted to a vector using the table's provided embedding function
the query. This will be converted to a vector using the table's provided embedding function,
or the query string for full-text search if `queryType` is "fts".
• **queryType**: `string` = `"auto"` \| `"fts"`
the type of query to run. If "auto", the query type will be determined based on the query.
• **ftsColumns**: `string[] | str` = undefined
the columns to search in. If not provided, all indexed columns will be searched.
For now, this can support to search only one column.
##### Returns

View File

@@ -37,6 +37,7 @@
- [IndexOptions](interfaces/IndexOptions.md)
- [IndexStatistics](interfaces/IndexStatistics.md)
- [IvfPqOptions](interfaces/IvfPqOptions.md)
- [FtsOptions](interfaces/FtsOptions.md)
- [TableNamesOptions](interfaces/TableNamesOptions.md)
- [UpdateOptions](interfaces/UpdateOptions.md)
- [WriteOptions](interfaces/WriteOptions.md)