Inf*_*ogy 5 match elasticsearch
我有两个指数my_index_1和my_index_2.在这些索引中,我有以下文档类型:
my_index_1:
my_index_2:
每种类型都有不同的字段.
我的问题: 在任何一个甚至两个索引中,在任何类型的任何字段中查询字符串"abc"的最佳方法是什么?
我没有在文档中看到任何有助于这种搜索的内容.有什么东西可能看起来像:
$ curl -XPOST 'localhost:9200/_search?pretty' -d '
{
"query": { "match": { *: "abc" } }
}'
Run Code Online (Sandbox Code Playgroud)
在此先感谢您提供的任何帮助.
tik*_*ock 19
GET /_search
{
"query": {
"multi_match" : {
"query": "Will Smith",
"fields": [ "important_field^5", "less_important^2", "title", "*_name" ]
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意字段名称中的通配符支持以及使用 ^# 语法提高字段重要性
从 version 7.3 开始:如果没有提供字段,则 multi_match 查询默认为 index.query.default_field 索引设置,而后者默认为 *。* 提取映射中符合术语查询条件的所有字段并过滤元数据字段。然后组合所有提取的字段以构建查询。
另一种选择是查询字符串查询
GET /_search
{
"query": {
"query_string" : {
"query" : "(new york city) OR (big apple)",
"default_field" : "content"
}
}
}
Run Code Online (Sandbox Code Playgroud)
default_field (可选,字符串)如果查询字符串中没有提供字段,则您希望搜索的默认字段。
默认为 index.query.default_field 索引设置,默认值为 *。
Val*_*Val 14
无论是query_string查询或match查询将是你在找什么.
query_string如果没有指定,将使用特殊_all字段default_field,这样可以很好地工作.
curl -XPOST 'localhost:9200/_search?pretty' -d '{
"query": { "query_string": { "query": "abc" } }
}'
Run Code Online (Sandbox Code Playgroud)
而随着match你可以指定_all为好.
curl -XPOST 'localhost:9200/_search?pretty' -d '{
"query": { "match": { "_all": "abc" } }
}'
Run Code Online (Sandbox Code Playgroud)
请注意,query_string您可以使用通配符,但不能使用通配符match
| 归档时间: |
|
| 查看次数: |
8556 次 |
| 最近记录: |