如何匹配弹性搜索查询部分匹配多个查询? [英] How to match elastic search query partial match multiple query?
本文介绍了如何匹配弹性搜索查询部分匹配多个查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的DSL查询低于
GET index_name/_search
{
"query" : {
"query_string" : {
"query" : "*avi*",
"fields" : [
"data.name"
]
}}}
我需要添加 query ; : * ojh * 也是如此。
以下查询不起作用
GET index_name/_search
{
"query" : {
"query_string" : {
"query" : "*avi*",
"query" : "*ojh*",
"fields" : [
"data.name"
]
}}}
推荐答案
您需要利用 bool / should
查询并添加两个 query_string
查询:
You need to leverage the bool/should
query and add two query_string
queries:
{
"query": {
"bool": {
"should": [
{
"query_string": {
"query": "*avi*",
"fields": [
"data.name"
]
}
},
{
"query_string": {
"query": "*ojh*",
"fields": [
"data.name"
]
}
}
]
}
}
}
不过,请注意,像这样进行中缀搜索可能会破坏群集的性能。请参阅此线程,了解如何正确执行 substring操作。搜索。
Just note, though, that doing infix searches like this can kill the performance of your cluster. See this thread on how to properly do "substring" searches.
这篇关于如何匹配弹性搜索查询部分匹配多个查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文