TairSearch is a full-text search data structure developed in-house based on Redis modules instead of Lucene or other open source search engine software libraries. TairSearch uses query syntax that is similar to that of Elasticsearch.
Overview
- All data and indexes are stored in memory to ensure higher throughput and lower read/write latency.
- Update of local indexes for documents is supported. Update operations include adding a field, updating a field, deleting a field, and auto-incrementing a field.
- Real-time indexes are supported. Data is immediately available after it is written.
Prerequisites
Precautions
- The TairSearch data that you want to manage is stored on the performance-enhanced instance.
- To reduce memory usage, we recommend that you perform the following operations:
- When you create indexes, set index to true for document fields to specify these fields as indexed fields. For other document fields, set index to false.
- Specify the includes and excludes properties of the _source field to filter out document fields that you do not need and save fields that you need.
- Do not add a large number of documents to a single index. Add the documents to multiple indexes. We recommend that you keep the number of documents per index within 500 million to prevent data skew in cluster instances, balance read and write traffic, and reduce the number of large keys and hotkeys.
Supported commands
Command | Syntax | Description |
---|---|---|
TFT.CREATEINDEX | TFT.CREATEINDEX index mappings |
Creates an index and a mapping for the index. The syntax used to create a mapping is similar to that used to create an explicit mapping in Elasticsearch. For more information, see Explicit mapping. You must create an index before you can add documents to the index. |
TFT.UPDATEINDEX | TFT.UPDATEINDEX index mappings |
Adds a properties field to the specified index. The field that you want to add cannot have the same name as an existing one. Otherwise, the field cannot be added. |
TFT.GETINDEX | TFT.GETINDEX index |
Obtains the mapping content of an index. |
TFT.ADDDOC | TFT.ADDDOC index document [WITH_ID doc_id] |
Adds a document to an index. You can specify a unique ID for the document in the index by using WITH_ID doc_id. If the document ID already exists, the existing ID is overwritten. If you do not specify WITH_ID doc_id, a document ID is automatically generated. By default, WITH_ID doc_id is not specified. |
TFT.MADDDOC | TFT.MADDDOC index document doc_id [document1 doc_id1] ... |
Adds multiple documents to an index. Each document must have a document ID that is specified by doc_id. |
TFT.UPDATEDOCFIELD | TFT.UPDATEDOCFIELD index doc_id document |
Updates the document specified by doc_id in an index. If the fields that you want
to add to the document are mapped and indexed fields, the fields must be of the same
data type as those used by the mapping. If the fields that you want to add are not
indexed fields, the fields can be of a random data type.
Note If the fields that you want to add to the document already exist, the document is
updated. If the fields that you want to add do not exist, the fields are added. If
the document does not exist, the document is automatically created. In this case,
the command is equivalent to TFT.ADDDOC.
|
TFT.DELDOCFIELD | TFT.DELDOCFIELD index doc_id field [field1 field2 ...] |
Deletes the specified fields from the document specified by doc_id in an index. If
the fields are indexed fields, the information in the fields is also deleted from
the index.
Note If the fields do not exist, the operation cannot be performed. For example, the fields
may not exist because they are filtered out by using _source.
|
TFT.INCRLONGDOCFIELD | TFT.INCRLONGDOCFIELD index doc_id field increment |
Adds an increment to the specified field in the document specified by doc_id in an
index. The increment can be a positive or negative integer. The data type of the field
can only be long or int.
Note If the document does not exist, the document is automatically created. In this case,
the existing value of the field is 0, and the updated field value is obtained by adding
the increment value to the existing field value. If the field does not exist, the
operation cannot be performed. For example, the field may not exist because it is
filtered out by using _source.
|
TFT.INCRFLOATDOCFIELD | TFT.INCRFLOATDOCFIELD index doc_id field increment |
Adds an increment to the specified field in the document specified by doc_id in an
index. The increment can be a positive or negative floating-point number. The data
type of the field can be int, long, or double.
Note If the document does not exist, the document is automatically created. In this case,
the existing value of the field is 0, and the updated field value is obtained by adding
the increment value to the existing field value. If the field does not exist, the
operation cannot be performed. For example, the field may not exist because it is
filtered out by using _source.
|
TFT.GETDOC | TFT.GETDOC index doc_id |
Obtains the content of the document specified by doc_id in an index. |
TFT.EXISTS | TFT.EXISTS index doc_id |
Checks whether the document specified by doc_id exists in an index. |
TFT.DOCNUM | TFT.DOCNUM index |
Obtains the number of documents in an index. |
TFT.SCANDOCID | TFT.SCANDOCID index cursor [MATCH *value*] [COUNT count] |
Obtains the IDs of all documents in an index. |
TFT.DELDOC | TFT.DELDOC index doc_id [doc_id] ... |
Deletes the document specified by doc_id from an index. Multiple document IDs can be specified. |
TFT.DELALL | TFT.DELALL index |
Deletes all documents from an index but retains the index. |
TFT.SEARCH | TFT.SEARCH index query |
Queries the documents in an index. The query syntax is similar to that of the Query Domain Specific Language (DSL) of Elasticsearch. For more information, see Query DSL. |
DEL | DEL key [key ...] |
Deletes one or more TairSearch keys. |
Command | Syntax | Description |
---|---|---|
TFT.ADDSUG | TFT.ADDSUG index text weight [text weight] ... |
Adds one or more auto-complete texts and their weights to the specified index. |
TFT.DELSUG | TFT.DELSUG index text [text] ... |
Deletes one or more auto-complete texts from the specified index. |
TFT.SUGNUM | TFT.SUGNUM index |
Obtains the number of auto-complete texts in the specified index. |
TFT.GETSUG | TFT.GETSUG index prefix [MAX_COUNT count] [FUZZY] |
Obtains the auto-complete texts that can be matched based on the specified prefix. Texts are returned in descending order of weights. |
TFT.GETALLSUGS | TFT.GETALLSUGS index |
Obtains the full auto-complete texts in the specified index. |
Uppercase keyword
: the command keyword.Italic
: Words in italic indicate variable information that you supply.[options]
: optional parameters. Parameters that are not included in brackets are required.AB
: specifies that these parameters are mutually exclusive. Select one of two or more parameters....
: specifies to repeat the preceding content.
TFT.CREATEINDEX
Item | Description |
---|---|
Syntax | TFT.CREATEINDEX index mappings |
Command description |
Creates an index and a mapping for the index. The syntax used to create a mapping is similar to that used to create an explicit mapping in Elasticsearch. For more information, see Explicit mapping. You must create an index before you can add documents to the index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.UPDATEINDEX
Item | Description |
---|---|
Syntax | TFT.UPDATEINDEX index mappings |
Command description |
Adds a properties field to the specified index. The field that you want to add cannot have the same name as an existing one. Otherwise, the field cannot be added. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.GETINDEX
Item | Description |
---|---|
Syntax | TFT.GETINDEX index |
Command description |
Obtains the mapping content of an index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.ADDDOC
Item | Description |
---|---|
Syntax | TFT.ADDDOC index document [WITH_ID doc_id] |
Command description |
Adds a document to an index. You can specify a unique ID for the document in the index by using WITH_ID doc_id. If the document ID already exists, the existing ID is overwritten. If you do not specify WITH_ID doc_id, a document ID is automatically generated. By default, WITH_ID doc_id is not specified. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.MADDDOC
Item | Description |
---|---|
Syntax | TFT.MADDDOC index document doc_id [document1 doc_id1] ... |
Command description |
Adds multiple documents to an index. Each document must have a document ID that is specified by doc_id. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.UPDATEDOCFIELD
Item | Description |
---|---|
Syntax | TFT.UPDATEDOCFIELD index doc_id document |
Command description |
Updates the document specified by doc_id in an index. If the fields that you want
to add to the document are mapped and indexed fields, the fields must be of the same
data type as those used by the mapping. If the fields that you want to add are not
indexed fields, the fields can be of a random data type.
Note If the fields that you want to add to the document already exist, the document is
updated. If the fields that you want to add do not exist, the fields are added. If
the document does not exist, the document is automatically created. In this case,
the command is equivalent to TFT.ADDDOC.
|
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.DELDOCFIELD
Item | Description |
---|---|
Syntax | TFT.DELDOCFIELD index doc_id field [field1 field2 ...] |
Command description |
Deletes the specified fields from the document specified by doc_id in an index. If
the fields are indexed fields, the information in the fields is also deleted from
the index.
Note If the fields do not exist, the operation cannot be performed. For example, the fields
may not exist because they are filtered out by using _source.
|
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.INCRLONGDOCFIELD
Item | Description |
---|---|
Syntax | TFT.INCRLONGDOCFIELD index doc_id field increment |
Command description |
Adds an increment to the specified field in the document specified by doc_id in an
index. The increment can be a positive or negative integer. The data type of the field
can only be long or int.
Note If the document does not exist, the document is automatically created. In this case,
the existing value of the field is 0, and the updated field value is obtained by adding
the increment value to the existing field value. If the field does not exist, the
operation cannot be performed. For example, the field may not exist because it is
filtered out by using _source.
|
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.INCRFLOATDOCFIELD
Item | Description |
---|---|
Syntax | TFT.INCRFLOATDOCFIELD index doc_id field increment |
Command description |
Adds an increment to the specified field in the document specified by doc_id in an
index. The increment can be a positive or negative floating-point number. The data
type of the field can be int, long, or double.
Note If the document does not exist, the document is automatically created. In this case,
the existing value of the field is 0, and the updated field value is obtained by adding
the increment value to the existing field value. If the field does not exist, the
operation cannot be performed. For example, the field may not exist because it is
filtered out by using _source.
|
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.GETDOC
Item | Description |
---|---|
Syntax | TFT.GETDOC index doc_id |
Command description |
Obtains the content of the document specified by doc_id in an index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.EXISTS
Item | Description |
---|---|
Syntax | TFT.EXISTS index doc_id |
Command description |
Checks whether the document specified by doc_id exists in an index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.DOCNUM
Item | Description |
---|---|
Syntax | TFT.DOCNUM index |
Command description |
Obtains the number of documents in an index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.SCANDOCID
Item | Description |
---|---|
Syntax | TFT.SCANDOCID index cursor [MATCH *value*] [COUNT count] |
Command description |
Obtains the IDs of all documents in an index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.DELDOC
Item | Description |
---|---|
Syntax | TFT.DELDOC index doc_id [doc_id] ... |
Command description |
Deletes the document specified by doc_id from an index. Multiple document IDs can be specified. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.DELALL
Item | Description |
---|---|
Syntax | TFT.DELALL index |
Command description |
Deletes all documents from an index but retains the index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.SEARCH
Item | Description |
---|---|
Syntax | TFT.SEARCH index query |
Command description |
Queries the documents in an index. The query syntax is similar to that of the Query Domain Specific Language (DSL) of Elasticsearch. For more information, see Query DSL. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.ADDSUG
Item | Description |
---|---|
Syntax | TFT.ADDSUG index text weight [text weight] ... |
Command description |
Adds one or more auto-complete texts and their weights to the specified index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.DELSUG
Item | Description |
---|---|
Syntax | TFT.DELSUG index text [text] ... |
Command description |
Deletes one or more auto-complete texts from the specified index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.SUGNUM
Item | Description |
---|---|
Syntax | TFT.SUGNUM index |
Command description |
Obtains the number of auto-complete texts in the specified index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.GETSUG
Item | Description |
---|---|
Syntax | TFT.GETSUG index prefix [MAX_COUNT count] [FUZZY] |
Command description |
Obtains the auto-complete texts that can be matched based on the specified prefix. Texts are returned in descending order of weights. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|
TFT.GETALLSUGS
Item | Description |
---|---|
Syntax | TFT.GETALLSUGS index |
Command description |
Obtains the full auto-complete texts in the specified index. |
Parameter |
|
Output |
|
Example |
Sample command:
Sample output:
|