简体   繁体   English

弹性搜索两个字段的查询

[英]Elastic search query for two fields

I'm trying to write a query for some products. 我正在尝试为某些产品编写查询。 Products have two fields, title and description. 产品有两个字段,标题和描述。 I'd like to write a query that passes in some text and returns to me products with matching text. 我想编写一个查询,该查询传递一些文本并返回具有匹配文本的产品。 I'd like all the products that have a match in the title to be ranked above all the products that have a match in the description. 我希望标题中具有匹配项的所有产品都排在描述中具有匹配项的所有产品之上。 I'd also like to have the description field matches to require a higher fuzziness and minimum should match than title matches. 我还希望描述字段匹配要求比标题匹配更高的模糊性,并且最小匹配应该匹配。

So far i've only been able to find ways to write queries that A) would check both fields, but matches for title and description would ranked equivalently or b) would check both fields, but would require a match in both fields before returning a result. 到目前为止,我只能找到写查询的方法,A)将检查两个字段,但是标题和描述的匹配项将被同等地排名,或者b)将检查两个字段,但是在返回a之前都需要两个字段都匹配结果。

Any help writing this in either the regular elastic search or using the FOSElasticaBundle would be much appreciated. 无论是在常规弹性搜索中还是在使用FOSElasticaBundle进行书写时,任何帮助均将不胜感激。

In elastic search you can make use of the query string query to provide different boost to different fields. 在弹性搜索中,您可以利用查询字符串查询为不同的字段提供不同的提升。 This supports boolean search texts also. 这也支持布尔搜索文本。 In case you do not need boolean search text then you can use multi-match query also. 如果您不需要布尔搜索文本,则也可以使用多重匹配查询

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM