elasticsearch-terms-execution

1
2
3
{
"terms" : { "field_name" : ["value1", "value2"], "execution" : "bool" }
}

“reason”: “[terms] query does not support [execution]”,
这种方式已经不支持了,目前只有用must没有找到更优雅的写法。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
POST /goods_index/_search
{
"explain": true,
"query": {
"bool": {
"filter": [
{
"bool": {
"must": [
{
"term": {
"categoryIds": {
"value": 1
}
}
},
{
"term": {
"categoryIds": {
"value": 2
}
}
}
]
}
}
]
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
POST /my_index/_search?pretty
{
"query": {
"terms": {
"color" : {
"index" : "my_index",
"id" : "3",
"path" : "color"
}
}
}
}

POST /my_index/_search?pretty
{
"query": {
"terms_set": {
"color": {
"terms": [
"green",
"blue"
],
"minimum_should_match_script": {
"source": "Math.min(params.num_terms, 4)"
},
"boost": 1
}
}
}
}

ps.