如何使用DSL查询搜索所有属性? [英] How to search in all attributes using DSL query?
问题描述
如何检查值是否包含字符串
How to check the value contain a string
下面是示例数据。我需要搜索任何属性,这些属性是 Thomas
Below is sample data. I need to search the any attributes which is Thomas
- 您可以看到我首先只有托马斯文件。因此,第一个文件必须返回。基本上一个文档(如果存在任何搜索字段)我需要检索该文档
{
"id": "Accounting 101",
"dataproduct": "E3",
"professor": {
"name": "Thomas Baszo",
"department": "finance",
"facutly_type": "part-time",
"email": "baszot@onuni.com"
},
"students_enrolled": 27,
"course_publish_date": "2015-01-19",
"course_description": "Act 101 is a course from the business school on the introduction to accounting that teaches students how to read and compose basic financial statements"
}
PUT /data/test/2
{
"name": "Accounting 101",
"room": "E3",
"professor": {
"name": "Sachin Baszo",
"department": "finance",
"facutly_type": "part-time",
"email": "baszot@onuni.com"
},
"students_enrolled": 27,
"course_publish_date": "2015-01-19",
"course_description": "Act 101 is a course from the business school on the introduction to accounting that teaches students how to read and compose basic financial statements"
}
推荐答案
您可以使用查询字符串在任何字段上搜索。
You can use query string to search on any field.
GET /_search
{
"query": {
"query_string": {
"query": "Thomas"
}
}
}
default_field
(可选,字符串)如果查询字符串中未提供任何字段,则希望搜索的默认字段。
default_field (Optional, string) Default field you wish to search if no field is provided in the query string.
默认为 index.query.default_field
索引设置,其默认值为 *
。 *
值提取所有符合条件查询的字段,并过滤元数据字段。如果未指定前缀,则将所有提取的字段组合在一起以构建查询。
Defaults to the index.query.default_field
index setting, which has a default value of *
. The *
value extracts all fields that are eligible for term queries and filters the metadata fields. All extracted fields are then combined to build a query if no prefix is specified.
这篇关于如何使用DSL查询搜索所有属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!