Azure Search - Find matches within a word like “contains”

本小妞迷上赌 提交于 2019-11-28 02:27:55

问题


I use Azure Search which in turn uses Lucene. Is there any way to make search not that strict. What I need is when searching for "term" should match documents with terms that contain "term".

Serching fox term should match "PrefixTerm", "TermSuffix", "PrefixTermSuffix"

Serching fox part2 should match "part1part2", "part2part3", "part1part2part3"

I need to run search query which has several terms like

"term part2"

To match documents like:

{ someField:"... PrefixTermSuffix ... part1part2part3 ..." }
{ someField:"... PrefixTerm ... part2part3 ..." }
etc

回答1:


You can use regex expression in Lucene query syntax in Azure Search. In your example, you can construct a regex query like /.term./ /.part2./ to find the documents with terms that contains the two search terms as substrings.

https://[service name].search.windows.net/indexes/[search index]/docs?api-version=2016-09-01&queryType=full&search=/.*term.*/ /.*part2.*/

Azure Search supports two query syntaxes, simple and full. The latter enables the Lucene query syntax. Please see our documentation (https://docs.microsoft.com/en-us/rest/api/searchservice/lucene-query-syntax-in-azure-search) to learn more about the capabilities.



来源:https://stackoverflow.com/questions/40893802/azure-search-find-matches-within-a-word-like-contains

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