我们正在尝试将筛选器功能实现到 Azure(认知)搜索中。我希望找到一些不错的 SDK 方法来隐藏所有丑陋的部分,但到目前为止我发现的唯一示例如下(source https://learn.microsoft.com/en-us/azure/search/search-security-trimming-for-azure-search-with-aad#step-2-compose-the-search-request):
SearchParameters parameters = new SearchParameters()
{
Filter = String.Format("groupIds/any(p:search.in(p, '{0}'))", string.Join(",", groups.Select(g => g.ToString()))),
Select = new[] { "application essays" }
};
我想知道我是否缺少一些文档。或者也许它在路线图上?
看看我们的新Azure.搜索.文档 https://www.nuget.org/packages/Azure.Search.Documents/我们上个月发布了 SDK。正如您所见,它确实有 OData 过滤器帮助here https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/search/Azure.Search.Documents/README.md#searchoptions:
int stars = 4;
SearchOptions options = new SearchOptions
{
// Filter to only Rating greater than or equal our preference
Filter = SearchFilter.Create($"Rating ge {stars}"),
Size = 5, // Take only 5 results
OrderBy = { "Rating desc" } // Sort by Rating from high to low
};
它将正确转义字符串参数。开放数据$filter
语法仍然需要原始输入,但格式化字符串中的类型帮助器应该使您的情况更容易:您不必担心自己转义值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)