Elasticsearch查询multi_match [英] Elasticsearch query multi_match

查看:87
本文介绍了Elasticsearch查询multi_match的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个弹性搜索查询,以查找多个字段.到目前为止,这个工作正常.但是,我想对此进行完善.假设该词已编入索引:测试".但是,当我搜索"tes"时,他没有找到适合我的单词,但是我已经想显示它了-但是与查询的结合使我面临挑战.

I'm trying to create an elasticsearch query that looks for multiple fields. This works fine so far. However, I would like to refine this. Let's say the word was indexed: "test". However, when I search for "tes" he does not find that word for me, but I would like to show it already - but the combination with my query brings me to a challenge.

             {
             "multi_match" : {
               "query":      "*" + query + "*",
               "type":       "cross_fields",
               "operator":   "and",
               "fields":     ["article.number^1","article.name_de^1", "article.name_en^5", "article.name_fr^5", "article.description^1"],
               "tie_breaker": 0,
             }

推荐答案

根据您的约束,这是您的选择.

Depending on your constraints, here are your options.

如果您希望在搜索字词之前/之后使用通配符,则可以使用

If you wish to use wildcard before/after your search term, you can use wildcard query. This has high processing cost at query time.

如果可以选择增加存储成本,则可以选择在分析过程中标记您的输入.请参见 ngram标记生成器.请注意,如果字符串很长,它可能会迅速激增存储需求.

If you are fine with additional storage cost, you can opt to tokenize your input during analysis process. See ngram tokenizer. Beware that if you have long strings, it can quickly explode the storage requirement.

这篇关于Elasticsearch查询multi_match的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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