When you perform a wildcard query, you can use the asterisk (*) and question mark (?) wildcard characters in the query to search for data. The asterisk (*) matches a string of any length at, before, or after a search term. The question mark (?) matches a single character in a specific position. The string can start with an asterisk (*) or a question mark (?). For example, if you search for the "table*e" string, "tablestore" can be matched.

The *word* string is equivalent to the WHERE field_a LIKE '%word%' clause in SQL. If you want to search for the *word* string, you can perform a fuzzy query that provides higher performance than a wildcard query. For more information about how to perform a fuzzy query, see Fuzzy query. If you perform a fuzzy query, the query performance is not compromised when the data volume increases.


  • The OTSClient 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 data table. For more information, see Create search indexes.


Parameter Description
Query The type of the query. Set the query type to WildcardQuery.
FieldName The name of the column.
Value The string that contains wildcards. The string cannot exceed 20 characters in length.
TableName The name of the data table.
IndexName The name of the search index.
GetTotalCount Specifies whether to return the total number of rows that match the query conditions. By default, the value of this parameter is false, which specifies that the total number of rows that match the query conditions is not returned.

If you set the GetTotalCount parameter to true, the query performance is compromised.

ColumnsToGet Specifies whether to return all columns of each matched row.

By default, the value of ReturnAll is false, which specifies that not all columns are returned. If ReturnAll is set to false, you can use ColumnsToGet to specify the columns that you want to return. If you do not specify the columns that you want to return, only the primary key columns are returned.

If you set the ReturnAll parameter to true, all columns are returned.


/// <summary>
/// Wildcard query. You can use an asterisk (*) and a question mark (?) as wildcards for wildcard queries. An asterisk (*) matches zero or more characters and a question mark (?) matches exactly one character. 
/// </summary>
/// <param name="otsClient"></param>
public static void WildcardQuery(OTSClient otsClient)
    var searchQuery = new SearchQuery();
    // Set the query type to WildcardQuery. The string based on which you want to match column values can contain wildcards. 
    searchQuery.Query = new WildcardQuery(Keyword_type_col, "*Search*");
    searchQuery.GetTotalCount = true;
    var request = new SearchRequest(TableName, IndexName, searchQuery);
    request.ColumnsToGet = new ColumnsToGet()
        ReturnAll = true

    var response = otsClient.Search(request);

    Console.WriteLine("Total Count:" + response.TotalCount);