Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-18835

Filters should not contribute to a document scoring

    XMLWordPrintable

    Details

      Description

      The filters on metadata (type, facets, lifecycle state ...) contribute to the document scoring. The score is not same for each document which sometimes results in a weird result order. Some results for a match query (OR) which contains all the keywords can appear after results that contains only some of the keywords because of the filters contribution (made a test with the API passthrough with explain set to true)

      The elasticsearch documentation says that filters (ES) must be used instead of query (and that filters are faster than queries):

      below is an example with ES 1.x

      "query": {
              "filtered": {
                "query": {
                  "bool": {
                    "must": [
                      {
                        "match": {
                          "_all": {
                            "query": "headache relief",
                            "operator": "OR",
                            "analyzer": "en_search_analyzer",
                            "fuzziness": "AUTO"
                          }
                        }
                      }
                    ]
                  }
                },
                "filter": {
                  "bool": {
                    "must": [
                      {
                        "term": {
                          "ecm:isVersion": "0"
                        }
                      },
                      {
                        "term": {
                          "ecm:primaryType": "Article"
                        }
                      },
                      {
                        "term": {
                          "ecm:currentLifeCycleState": "approved"
                        }
                      }
                    ],
                    "must_not": [
                      {
                        "term": {
                          "ecm:mixinType": "HiddenInNavigation"
                        }
                      }
                    ]
                  }
                }
              }
            }
      

      instead of

       "query" : {
          "bool" : {
            "must" : [ {
              "match" : {
                "_all" : {
                  "query" : "headache relief",
                  "type" : "boolean",
                  "operator" : "OR",
                  "analyzer" : "en_search_analyzer",
                  "fuzziness" : "AUTO"
                }
              }
            }, {
              "bool" : {
                "must" : [ {
                  "constant_score" : {
                    "filter" : {
                      "not" : {
                        "filter" : {
                          "term" : {
                            "ecm:mixinType" : "HiddenInNavigation"
                          }
                        }
                      }
                    }
                  }
                }, {
                  "constant_score" : {
                    "filter" : {
                      "term" : {
                        "ecm:isVersion" : "0"
                      }
                    }
                  }
                }, {
                  "constant_score" : {
                    "filter" : {
                      "not" : {
                        "filter" : {
                          "term" : {
      
      

        Attachments

        1. query.json
          1 kB
        2. result.json
          100 kB
        3. query_with_filter.json
          1 kB
        4. result_with_filter.json
          7 kB

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: