Optimization question

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
}

Why is that a lot? What are you comparing it to that is fast?

It's a search query, so ~1 second response time for ~3.5k total hits is a lot, honestly, given the fact that over 50k values can be listed in under 10ms for a simple search query (without any inner hits or related stuff)...

Oh right, it's not obvious from your original post as you only mention the 150ms :slight_smile:

Oh, ok, no problem, sorry for that. As a conclusion, I need help to somehow optimize the query to get a much better response time, as I cannot continue the research only by myself, because time is not my friend... :frowning: Thanks in advance!

LE: I am using Elastic 5.6 :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.