Thanks @rjernst.
Another question, i have created two scripts and execute both inside query->bool->must, but the scripts are execute with the condition OR, script1 = true or script2 = true, is possible return just the data when both scripts return true?
Query:
{
"query": {
"bool": {
"must": [
{
"term": {
"active": true
}
},
{
"script": {
"script": [
{
"id": "script_query_1",
"params": {
"list": [
1
],
"current_timestamp": 1522344053924
}
},
{
"id": "script_query_2",
"params": {
"list": [
1
],
"current_timestamp": 1522344053924
}
}
]
}
}
]
}
},
"script_fields": {
"deadline_cumprido": {
"script": {
"id": "script_query_1",
"params": {
"list": [1],
"current_timestamp": 1522344053924
}
}
},
"start_deadline_cumprido": {
"script": {
"id": "script_query_2",
"params": {
"list": [1],
"current_timestamp": 1522344053924
}
}
}
}
}
Result:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 2.0,
"hits": [
{
"_index": "myindex_example",
"_type": "doc_example",
"_id": "2648374-14492",
"_score": 2.0,
"fields": {
"script_query_2": [
true
],
"script_query_1": [
true
]
}
},
{
"_index": "myindex_example",
"_type": "doc_example",
"_id": "2648373-14492",
"_score": 2.0,
"fields": {
"script_query_2": [
true
],
"script_query_1": [
true
]
}
},
{
"_index": "myindex_example",
"_type": "doc_example",
"_id": "2648375-14492",
"_score": 2.0,
"fields": {
"script_query_2": [
true
],
"script_query_1": [
false
]
}
}
]
}
}