I am using a function score with a function filter to score a subset of 
results higher. I specify to cache the function filter, but its performance 
is slower and slower the more clauses I add to the filter.

A query with 2 geo_polygons clauses returns relatively fast (30ms), but the 
more polygons clauses I add the slower it gets. With 50 polygons the call 
slows to 1s. Does elasticsearch actually cache the filter?

Example query with 2 geo_polygons clauses:
{
  "query": {
    "function_score": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "city": "LA"
              }
            }
          ]
        }
      },
      "functions": [
        {
          "filter": {
            "bool": {
              "should": [
                {
                  "geo_polygon": {
                    "location": {
                      "points": [
                        [
                          -118.3971081,
                          34.081519
                        ],
                        [
                          -118.3440351,
                          34.081519
                        ],
                        [
                          -118.3440351,
                          34.131086
                        ],
                        [
                          -118.3971081,
                          34.131086
                        ]
                      ]
                    }
                  }
                },
                {
                  "geo_polygon": {
                    "location": {
                      "points": [
                        [
                          -118.3907139,
                          34.05576
                        ],
                        [
                          -118.361375,
                          34.05576
                        ],
                        [
                          -118.361375,
                          34.083811
                        ],
                        [
                          -118.3907139,
                          34.083811
                        ]
                      ]
                    }
                  }
                }
              ],
              "_cache": true
            }
          },
          "boost_factor": 2
        }
      ],
      "score_mode": "sum"
    }
  }
}

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/c990d908-2b15-4797-9300-22a71aeb4972%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to