Search using StartsWith in Azure Search

半城伤御伤魂 提交于 2019-12-06 10:29:18

From Nate Ko's answer here:

It looks like you want to issue a prefix search query on the entire field value not on the individual terms in the fields. In such case, you need to use keyword analyzer so that the entire field value is tokenized into a single token. For example, given "16th Ave SE" as input, by default Azure Search uses standard analyzer and tokenizes the input into multiple terms as <16th>, , and the prefix search is issued on the tokenized terms. If you use the keyword analyzer instead, the entire field value is tokenized as the single token as <16th ave se> and a prefix search search=16th* will only find documents with field that starts with the prefix. Likewise, the suffix search via regex search=/.*ave/ will only find docs with fields that ends with the suffix. Below are related questions on stackoverflow.

http://stackoverflow.com/questions/40056213/behavior-of-asterisk-in-azure-search-service/40137948#40137948

http://stackoverflow.com/questions/40857057/how-to-practially-use-a-keywordanalyzer-in-azure-search

Both Simple query syntax and Lucene query syntax support prefix search queries like "prefix*"and find documents that contain terms that starts with the prefix query.

So you can try something like search=info*"&searchmode=all or search=infosys tech*&searchmode=all and it should work.

If you want even more advanced regular expression like searches, you can refer to Regular expression search

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