簡體   English   中英

帶斜線的 Azure 搜索搜索

[英]Azure Search search with slash

我正在使用 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);
            }
        }

一切正常,直到搜索詞包含斜線。 例如,我正在尋找編號為“1508/W/2020”的訂單。 當我使用 SearchTerm = "1508" 進行搜索時,它可以工作。 當 SearchTerm = "1508/W" 時,它什么都不返回。 我嘗試用\\\\轉義斜杠,但它仍然不起作用。 你能給我建議任何解決方案嗎?

評論是正確的。 要轉義/ ,您應該使用這種格式\\/而不是\\\\

有關更多詳細信息,您可以參考此官方文檔進行特殊字符轉義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM