[英]Elasticsearch query syntax
I have a index with a mapping as follows我有一个映射索引如下
"mappings": {
"properties": {
"name": {
"type": "text"
},
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean"
},
"attributes": {
"dynamic": true,
"properties": {
"subjects": {
"type": "integer"
},
"occupation": {
"type": "integer"
}
}
Now I want to get all documents with occupation =4 and name not like 'Test' and is_active = True I have written following to get all documents with is_active=True and occupation 4, but I am not sure how to filter out documents where name contains 'test'现在我想获取所有职业 =4 且名称不类似于 'Test' 和 is_active = True 的文档包含“测试”
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"terms": {
"audience_attributes.occupation": [
4
]
}
}
]
}
},
{
"terms": {
"is_active": [
true
]
}
}
]
}
}
}
I am using Elasticsearch 7.9我正在使用 Elasticsearch 7.9
I think I got it我想我明白了
{
"query": {
"bool": {
"must_not": {
"wildcard": {
"name": {
"value": "*TEST*"
}
}
},
"must": [
{
"bool": {
"should": [
{
"terms": {
"audience_attributes.occupation": [
4
]
}
}
]
}
},
{
"terms": {
"is_active": [
true
]
}
}
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.