PrefixQuery根据前缀条件查询表中的数据。对于分词字符串类型(TEXT),只要分词后的词条中有词条满足前缀条件即可。

/// <summary>
/// 前缀查询。
/// </summary>
/// <param name="otsClient"></param>
public static void PrefixQuery(OTSClient otsClient)
{
    var searchQuery = new SearchQuery();
    //设置查询类型为PrefixQuery,匹配字段为Keyword_type_col,前缀值为"Search"
    searchQuery.Query = new PrefixQuery(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);
}