如何在Azure搜索中仅在集合的一个字符串内进行搜索? [英] How to search only inside one string of a Collection in Azure Search?

查看:89
本文介绍了如何在Azure搜索中仅在集合的一个字符串内进行搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个收集字段,例如:

I've a collection fields like:

["city of god"]
["god of war", "city of war"]

我想在带有"city"和"god"的字段上进行搜索,我只希望返回上帝之城".

I want to perform a search on the field with 'city' AND 'god' and I want only 'city of god' to be returned.

但是,无论集合中两个不同的字符串中的术语如何,也将返回第二个字段.

Yet, the second field is also return regardless of the terms being in two different strings within the collection.

是否要使搜索严格限于字符串内而不是整个集合内?

Anyway to make the search strict to within strings and not to the entire collection?

推荐答案

索引中的每个可搜索字段都被视为一揽子术语,因此对于"city AND god",您可以在该字段中对该字段的所有术语进行匹配整个文档,而不仅仅是子文档中的术语(在本例中为集合中的单个字符串).

Each searchable field in the index is treated as a bag of terms, so for "city AND god" you’re matching on all terms of that field in the whole document, not only the terms within sub-documents (in this case individual strings in the collection).

一种解决此问题的方法是在一个集合的单个字符串中指定这些词之间的合理距离估计,并使用该估计来发布

One way to get around this would be to specify a reasonable estimate of distance between these terms within a single string of a collection and use that to issue a proximity search query to get the desired result. For your specific example, assuming that the terms would be within 5 words of each other, the following query should work -

                 &queryType=full&search=fieldName:"city god"~5

使用邻近搜索非常有用,因为它可以帮助短语不必在短语查询中按提供的顺序具有足够大的邻近值,例如"city god"〜5也会匹配上帝保佑城市"

Using proximity search is really useful as it helps that words don’t have to be in the provided order in the phrase query with large enough proximity value e.g., "city god"~5 would also match "god bless the city".

请确保在查询字符串中包含queryType=full,因为邻近搜索是完整查询语法的一部分,否则将不起作用.您可以在此处查看其他示例.

Make sure to include queryType=full in your query string as proximity search is part of the full query syntax and would not work otherwise. You can check some other examples here.

这篇关于如何在Azure搜索中仅在集合的一个字符串内进行搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆