How can I use AzureSearch with wildcard

时间秒杀一切 提交于 2019-12-06 07:01:11

You can get your desired result by performing a full query with Lucene syntax (as noted by Sumanth BM). The trick is to do a regex search. Modify your query params like so:

{
 "queryType": "full",
 "search": "/.*searchterm.*/",
 "count":true,
 "top":10
}

Replace 'searchterm' with what you are looking for and azure search should return all matches from your index searchable columns.

See Doc section: MS Docs on Lucene regular expression search

You can use generally recognized syntax for multiple () or single (?) character wildcard searches. Note the Lucene query parser supports the use of these symbols with a single term, and not a phrase. For example to find documents containing the words with the prefix "note", such as "notebook" or "notepad", specify "note".

Note You cannot use a * or ? symbol as the first character of a search. No text analysis is performed on wildcard search queries. At query time, wildcard query terms are compared against analyzed terms in the search index and expanded.

SearchMode parameter considerations The impact of searchMode on queries, as described in Simple query syntax in Azure Search, applies equally to the Lucene query syntax. Namely, searchMode in conjunction with NOT operators can result in query outcomes that might seem unusual if you aren't clear on the implications of how you set the parameter. If you retain the default, searchMode=any, and use a NOT operator, the operation is computed as an OR action, such that "New York" NOT "Seattle" returns all cities that are not Seattle.

https://docs.microsoft.com/en-us/rest/api/searchservice/simple-query-syntax-in-azure-search

Reference: https://docs.microsoft.com/en-us/rest/api/searchservice/lucene-query-syntax-in-azure-search#bkmk_wildcard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!