在 Azure Search .NET SDK 中,如何传递搜索文本?

In Azure Search .NET SDK, how to pass the search text?

我正在尝试使用通配符表达式构建 lucene 全文搜索来表示 "Contains" /*.<Keyword>/*,但是在 Azure 搜索库提供的 Buildparameter 模型中没有搜索属性.

我正在使用

Documents.Search<T>(searchTerm, searchParam);

//where SearchTerm is the <typed key search> for ex "Nurs" and the result 
//should be where all or any text contains "Nurs"

我用来构建的 Azure.Search.Models SearchParameter 是我扩展以创建新的 class 以包含搜索字段的地方。

        return new ExtentedSearchParameter
         {
            IncludeTotalResultCount = true,
            SearchFields = new List<string>() {"FilterableTitle", "FilterableAlternativeTitle"},
            Skip = (properties.Page - 1) * properties.Count,
            Top = properties.Count,
            Search=properties.SearchQuery,
            QueryType = QueryType.Full ,
            Select=new List<string>(){"FilterableTitle", "FilterableAlternativeTitle"},
            OrderBy = properties.OrderByFields,
        };

在我的应用程序中,我构建的查询类似于

  if (string.IsNullOrWhiteSpace(returnProperties.FilterBy))
        {
            returnProperties.SearchQuery =$"FilterableTitle: /.*'{cleanSearchTerm.TrimStart('\"').TrimEnd('\"')}.*/' and FilterableAlternativeTitle:/.*'{cleanSearchTerm.TrimStart('\"').TrimEnd('\"')}.*/'";
        }

当我传递搜索参数和搜索词时,它不返回结果并抛出异常。

您可以将 Lucene 查询作为 searchText 参数传递给 Search 方法,而不是扩展 SearchParameters class:

Documents.Search<T>(properties.SearchQuery, searchParam);