Expecting another result(scoring) on function_score

Hi everybody,

I am wondering about the scoring of my query. I am using a function_score on the field weight of my documents. If I search for the term wien two documents are coming from two indices.

Here my query:

GET _all/_search
{
 "query": {
  "function_score" : {
    "query" : {
      "bool" : {
        "should" : [
          {
            "bool" : {
              "must" : [
                {
                  "multi_match" : {
                    "query" : "wien",
                    "fields" : [
                      "city.name_de^1.0"
                    ],
                    "type" : "best_fields",
                    "operator" : "OR",
                    "slop" : 0,
                    "fuzziness" : "0",
                    "prefix_length" : 0,
                    "max_expansions" : 50,
                    "lenient" : false,
                    "zero_terms_query" : "NONE",
                    "boost" : 1.0
                  }
                }
              ],
              "filter" : [
                {
                  "term" : {
                    "_index" : {
                      "value" : "city",
                      "boost" : 1.0
                    }
                  }
                },
                {
                  "term" : {
                    "enabled" : {
                      "value" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "should" : [
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                },
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                }
              ],
              "disable_coord" : false,
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          },
          {
            "bool" : {
              "must" : [
                {
                  "multi_match" : {
                    "query" : "wien",
                    "fields" : [
                      "servicename.name_de^1.0"
                    ],
                    "type" : "best_fields",
                    "operator" : "OR",
                    "slop" : 0,
                    "fuzziness" : "0",
                    "prefix_length" : 0,
                    "max_expansions" : 50,
                    "lenient" : false,
                    "zero_terms_query" : "NONE",
                    "boost" : 1.0
                  }
                }
              ],
              "filter" : [
                {
                  "term" : {
                    "_index" : {
                      "value" : "servicename",
                      "boost" : 1.0
                    }
                  }
                },
                {
                  "term" : {
                    "enabled" : {
                      "value" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "should" : [
                {
                  "bool" : {
                    "disable_coord" : false,
                    "adjust_pure_negative" : true,
                    "boost" : 1.0
                  }
                }
              ],
              "disable_coord" : false,
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          }
        ],
        "disable_coord" : false,
        "adjust_pure_negative" : true,
        "boost" : 1.0
      }
    },
    "functions" : [
      {
        "filter" : {
          "match_all" : {
            "boost" : 1.0
          }
        },
        "field_value_factor" : {
          "field" : "weight",
          "factor" : 1.0,
          "modifier" : "none"
        }
      }
    ],
    "score_mode" : "multiply",
    "max_boost" : 3.4028235E38,
    "boost" : 1.0
  }
}
}

(because of limitation of 7000 chars)...
On the other side my result:

"hits": [
  {
    "_index": "city",
    "_type": "city",
    "_id": "589",
    "_score": 377704.28,
    "_source": {
      "svno": 589,
      "city": {
        "name": "Wien",
        "name_de": "Wien",
        "name_it": "Vienna",
        "name_fr": "Vienne",
        "name_hu": "Bécs",
        "name_cs": "Vídeň"
      },
      "regions": [
        {
          "name": "Wien",
          "name_de": "Wien",
          "name_it": "Vienne",
          "name_fr": "Vienna",
          "name_hu": "Bécs",
          "name_cs": "Vídeň"
        }
      ],
      "nation": {
        "name": "Österreich",
        "name_de": "Österreich",
        "name_it": "Austria",
        "name_fr": "Autriche",
        "name_hu": "Ausztria",
        "name_cs": "Rakousko"
      },
      "location": {
        "lat": 48.20827865600586,
        "lon": 16.373079299926758
      },
      "weight": 32300
    }
  },
  {
    "_index": "servicename",
    "_type": "servicename",
    "_id": "593",
    "_score": 279269.25,
    "_source": {
      "id": "593",
      "servicename": {
        "name": "Wien",
        "name_de": "Wien",
        "name_it": "Vienne",
        "name_fr": "Vienna",
        "name_hu": "Bécs",
        "name_cs": "Vídeň"
      },
      "city": null,
      "region": {
        "svno": 593,
        "regions": [
          {
            "name": "Wien",
            "name_de": "Wien",
            "name_it": "Vienne",
            "name_fr": "Vienna",
            "name_hu": "Bécs",
            "name_cs": "Vídeň"
          }
        ],
        "nation": {
          "name": "Österreich",
          "name_de": "Österreich",
          "name_it": "Austria",
          "name_fr": "Autriche",
          "name_hu": "Ausztria",
          "name_cs": "Rakousko"
        }
      },
      "theme": null,
      "contract": null,
      "enabled": true,
      "weight": 35300
    }
  }
	]

I dont understand why the result of the city index has a higher score than the result of the servicename index. The weight on servicename is 35300 and from city is 32300.

I expect that the servicename document should be the best result.

Do you have any explanation for that?

Thanks!

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