如何在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)
我不想将两个字段映射为一个字段,因为我想在平局时区分它们,因此,例如对于queryfox
,正确的结果是:
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)