我有两个索引my_index_1和my_index_2。在这些索引中,我具有以下文档类型:
my_index_1
my_index_2
my_index_1:
my_index_2:
每种类型都有不同的字段。
我的问题: 在任何类型的任何字段中,跨一个或什至两个索引查询字符串“ abc”的最佳方法是什么?
我没有在文档中找到任何有助于这种搜索的内容。是否有可能看起来像:
$ curl -XPOST 'localhost:9200/_search?pretty' -d ' { "query": { "match": { *: "abc" } } }'
预先感谢您提供的任何帮助。
无论是query_string查询或match查询将是你在找什么。
query_string
match
query_string如果未指定,将使用特殊_all字段default_field,因此效果很好。
_all
default_field
curl -XPOST 'localhost:9200/_search?pretty' -d '{ "query": { "query_string": { "query": "abc" } } }'
并且,match您也可以指定_all。
curl -XPOST 'localhost:9200/_search?pretty' -d '{ "query": { "match": { "_all": "abc" } } }'
请注意,query_string您可能会使用通配符,而不能使用通配符match
更新:
由于该_all字段在6.0中已弃用,因此解决方案是实现自定义所有字段