Hello,
I have been trying to optimize an Elasticsearch query for a few days, but I did not manage to get what I wanted. The scenario is the following: there are cars (as the main parent, containing some basic details), user cars (child of cars, being added by users, so they can be considered variations of their parent car; parent field is id_car) and user cars languages (child of user cars, which contain text information related to a language, like name and description in english + in french + in german etc; parent field is id_user_car). Want I am doing is searching by a given word/sentence into user cars languages values and I retrive what I find + parent user car + parent car. You can see how I got it working from the schema below, but the problem is that I really do not like the response time I get. For example, for a number of ~500 total hits, I get ~150ms response time, which is A LOT. Is there any other way, at all, to do what I want and get a much better response time?
Thank you for your time!
{
"query": {
"has_child": {
"type": "user_car",
"inner_hits": {
"_source": "false",
"size": 1,
"sort": [
{
"price": {
"order": "asc",
"mode": "min"
}
}
]
},
"filter": {
"has_child": {
"type": "user_car_lang",
"inner_hits": {
"_source": "false",
"size": 1
},
"filter": {
"bool": {
"must": [
{
"term": {
"id_lang": 1
}
},
{
"multi_match": {
"query": "bmw",
"fields": [
"name",
"description"
],
"operator": "and"
}
}
]
}
}
}
}
}
},
"_source": "false",
"size": 1000
}