Optimizing Queries: Avoid Scoring on Nested Objects


(Michael Sander) #1

I have been using the search profiler in Kibana 5.x to try to optimize some of my queries. I have been testing the relatively simple query below, which only has a single term filter as well as a somewhat more complex rescore. Unfortunately, this query takes 1.7S to run and so I'm trying to optimize it.

A screenshot of the optimization is listed further below. In the screenshot, you can see an area with a red border that I added, which contains a lot of queries being performed on nested objects. My mapping has nested objects, but this query does not interact with them.

Can someone explain why the nested queries are being included in the query? Also, they seem to be hurting performance, how can I ignore them in the scoring process (they don't add much to relevance).

{
  "rescore": {
    "window_size": 100,
    "query": {
      "rescore_query": {
        "function_score": {
          "boost_mode": "multiply",
          "functions": [
            {
              "filter": {
                "term": {
                  "is_document": false
                }
              },
              "weight": 20
            },
            {
              "filter": {
                "term": {
                  "is_opinion": true
                }
              },
              "weight": 2
            }
          ],
          "score_mode": "multiply"
        }
      },
      "score_mode": "multiply"
    }
  },
  "query": {
    "bool": {
      "filter": {
        "term": {
          "court_exact": "Patent Trial and Appeal Board"
        }
      },
      "must": {
        "match_all": {}
      }
    }
  },
  "from": 0,
  "size": 8
}


(system) #2

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