{
"took": 13,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "car_db",
"_type": "_doc",
"_id": "11",
"_score": 1.0,
"_source": {
"searchResults": [
{
"beginTime": "2024-01-10T10:00:00+00:00",
"nicknames": ["a_random_value"],
"id": 6,
"automobileId": 11,
"finishedTime": "2024-01-20T10:00:00+00:00"
}
]
}
},
{
"_index": "car_db",
"_type": "_doc",
"_id": "13",
"_score": 1.0,
"_source": {
"searchResults": [
{
"beginTime": "2024-01-22T10:00:00+00:00",
"nicknames": ["a_random_value"],
"id": 8,
"automobileId": 13,
"finishedTime": "2024-01-25T10:00:00+00:00"
}
]
}
}
]
}
}
If I use:
GET /car_db/_search
{
"_source": ["searchResults"],
"query": {
"exists": {
"field": "searchResults"
}
},
"size": 1000
}
I am able to get the list and content as expected. However I need to use scriptQuery because I am trying to do more advanced stuff. However once I use script query I can not get the content of the searchResults.
type or paste code here
How can I achieve the same response using something like:
GET /car_db/_search
{
"_source": true,
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": """
if (doc.containsKey('searchResults') && doc['searchResults'].size() > 0) {
return true;
} else {
return false;
}
"""
}
}
}
}
}
}
Ofcourse once I get that to work I will modify it for more advanced operations.
type or paste code here