Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带斜杠的Azure搜索_C#_Azure_Azure Cognitive Search - Fatal编程技术网

C# 带斜杠的Azure搜索

C# 带斜杠的Azure搜索,c#,azure,azure-cognitive-search,C#,Azure,Azure Cognitive Search,我正在使用Azure认知搜索 private async Task PerformSearchAsync<T>(SearchServiceDocumentsQueryParameters parameters, SearchClient searchClient, ICollection<T> outputCollection) where T : BaseSearchIndexObject { var se

我正在使用Azure认知搜索

private async Task PerformSearchAsync<T>(SearchServiceDocumentsQueryParameters parameters, SearchClient searchClient, ICollection<T> outputCollection)
            where T : BaseSearchIndexObject
        {
            var searchResponse = await searchClient.SearchAsync<T>(parameters.SearchTerm, new SearchOptions
            {
                Filter = parameters.Filter,
                IncludeTotalCount = true,
                Size = parameters.MaxItemsCount
            });
            await foreach (var searchResult in searchResponse.Value.GetResultsAsync())
            {
                if(outputCollection.All(d => d.Id != searchResult.Document.Id))
                    outputCollection.Add(searchResult.Document);
            }
        }
专用异步任务PerformSearchSync(SearchServiceDocumentsQueryParameters参数、SearchClient SearchClient、ICollection outputCollection)
其中T:BaseSearchIndexObject
{
var searchResponse=await searchClient.SearchAsync(parameters.SearchTerm,new SearchOptions
{
过滤器=参数。过滤器,
IncludeTotalCount=true,
大小=参数。MaxItemsCount
});
等待foreach(searchResponse.Value.GetResultsAsync()中的var searchResult)
{
if(outputCollection.All(d=>d.Id!=searchResult.Document.Id))
outputCollection.Add(searchResult.Document);
}
}

在搜索词包含斜杠之前,一切正常。例如,我正在寻找编号为“1508/W/2020”的订单。当我使用SearchTerm=“1508”进行搜索时,它会起作用。当SearchTerm=“1508/W”时,它不返回任何内容。我尝试用
\\
来转义斜杠,但仍然不起作用。你能给我建议什么解决办法吗?

评论是正确的。要转义
/
,应使用此格式
\/
,而不是
\


有关更多详细信息,您可以参考此以获取特殊字符转义。

请注意,正斜杠的正确转义顺序是
\/
,而不是
\\
。您好,如果答案有帮助,请按照接受它作为答案?只需要几秒钟,谢谢。