您好,我正在尝试在ES中搜索通配符查询,现在要在多个字段中进行搜索,我可以有两种方法,首先使用query_string搜索该词。
{
"query": {
"query_string": {
"fields": ["title", "description", "state"],
"query": "Ban*",
"lowercase_expanded_terms": false
}
}
}
或
我可以使用 bool(boolean) 查询,在其中我可以编写多个通配符查询来执行此操作,而我的问题是你们都认为哪一个是快速且适当的。
"bool": {
"should": [
{"query": {"wildcard": {"title": {"value": "Ban*"}}}},
{"query": {"wildcard": {"description": {"value": "Ban*"}}}},
{"query": {"wildcard": {"taste": {"value": "Ban*"}}}}
]
}
最佳答案
Lucene查询字符串查询只是将查询字符串转换为具有这些简单查询(例如match,wildcard,regexp)等的bool查询。
因此,您应该不会看到任何区别。
关于elasticsearch - 在ES通配符v/s query_string中,用于查询多个字段的哪个更快,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33844942/