You can use asterisks (*) and question marks (?) to search for data that matches wildcards. An asterisk (*) represents any number of characters. A question mark (?) represents any single character. The matched value can start with asterisks (*) or question marks (?). For example, if you search for string "table*e", you can retrieve query results such as "tablestore".
Prerequisites
- The OTSClient instance is initialized. For more information, see Initialization.
- A data table is created. Data is written to the table.
- A search index is created for the table. For more information, see Create a search index.
Parameters
Parameter | Description |
---|---|
table_name | The name of the table. |
index_name | The name of the search index. |
offset | Specifies the position from which the current query starts. |
limit | Specifies the maximum number of items that the current query returns. |
get_total_count | Specifies whether to return the total number of matched rows. The default value is
false, which indicates that the total number of rows in the table is not returned.
If get_total_count is set to true, the query performance is affected. |
query_type | The query type. Set the query type to QueryTypeConst::WILDCARD_QUERY. |
field_name | The column name. |
value | The string that contains wildcards. The string cannot exceed 10 bytes in length. |
sort | The sorting method. Sort based on the specified method. For more information, see Sorting and paging. |
columns_to_get | Specifies whether to return all columns.
|
Examples
$request = array(
'table_name' => 'php_sdk_test',
'index_name' => 'php_sdk_test_search_index',
'search_query' => array(
'offset' => 0,
'limit' => 2,
'get_total_count' => true,
'query' => array(
'query_type' => QueryTypeConst::WILDCARD_QUERY,
'query' => array(
'field_name' => 'keyword',
'value' => 'key*'
)
),
'sort' => array(
array(
'field_sort' => array(
'field_name' => 'keyword',
'order' => SortOrderConst::SORT_ORDER_ASC
)
),
)
),
'columns_to_get' => array(
'return_type' => ColumnReturnTypeConst::RETURN_SPECIFIED,
'return_names' => array('keyword')
)
);
$response = $otsClient->search($request);