Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ElasticSearch中使用公共术语查询搜索多个字段?_Search_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch - Fatal编程技术网 elasticsearch,Search,elasticsearch" /> elasticsearch,Search,elasticsearch" />

如何在ElasticSearch中使用公共术语查询搜索多个字段?

如何在ElasticSearch中使用公共术语查询搜索多个字段?,search,elasticsearch,Search,elasticsearch,我正在对多个字段进行搜索,我希望避免使用通用术语,并希望合并所有字段的结果。目前,我得到了以下信息(截止频率,升压,布尔必须过滤器,等等。为了使问题更明显,省略了这些信息): 假设我有以下记录: id: 1 title: 'Fox' description: 'Small fox' id: 2 title: 'Fox' description: 'Is quick' id: 3 title: 'Legendary' description: 'Quick brown fox' 我的查询是快

我正在对多个字段进行搜索,我希望避免使用通用术语,并希望合并所有字段的结果。目前,我得到了以下信息(
截止频率
升压
布尔必须过滤器
,等等。为了使问题更明显,省略了这些信息):

假设我有以下记录:

id: 1
title: 'Fox'
description: 'Small fox'

id: 2
title: 'Fox'
description: 'Is quick'

id: 3
title: 'Legendary'
description: 'Quick brown fox'
我的查询是快速棕色狐狸。在上面的解决方案中,id 1和id 2的得分最高,因为它们匹配2个
shoulds
中的2个。id为3的记录在
标题中没有匹配项,因此应该匹配的
中只有1个

正确的顺序应该是

id: 3 (matches 3 words)
id: 2 (matches 2 words)
id: 1 (matches 1 word, even tough twice)
我不想将两个字段映射为一个字段,因为我想在平局时区分它们,因此,例如对于query
fox
,正确的结果是:

id: 1 (matches twice)
id: 2 (matches once but in the title)
id: 3 (matches once but in the description)
如果您对此有任何建议,我们将不胜感激。谢谢

id: 1 (matches twice)
id: 2 (matches once but in the title)
id: 3 (matches once but in the description)