如何将AzureSearch与通配符一起使用 [英] How can I use AzureSearch with wildcard
问题描述
我想搜索名称为"14009-00080300"的字段,并且只想搜索其中的一部分(例如"14009-000803")时,就会得到匹配.
I want to search for a field that has the name "14009-00080300", and I want to get a hit when searching only on a part of that, for example "14009-000803".
使用此代码,我没有获得任何成功:
Using this code I dont get any hits:
{
"search": "\"14009-000803\"*",
"count":true,
"top":10
}
有没有一种方法可以像SQL使用通配符搜索那样使用天蓝色搜索? (从表中选择*,其中col喜欢'%abc%'吗?
Is there a way to use azure search like SQL uses its wildcard search? (select * from table where col like '%abc%' ?
推荐答案
您可以通过使用Lucene语法执行完整查询(如Sumanth BM所述)来获得所需的结果.诀窍是进行正则表达式搜索.像这样修改查询参数:
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
}
将"searchterm"替换为您要查找的内容,并且天蓝色"搜索应返回索引可搜索列中的所有匹配项.
Replace 'searchterm' with what you are looking for and azure search should return all matches from your index searchable columns.
请参阅文档"部分: 查看全文