elasticsearch Elasticsearch:搜索分数让我困惑。不同级别的比赛分数相同,elasticsearch,kibana,elasticsearch,Kibana" /> elasticsearch Elasticsearch:搜索分数让我困惑。不同级别的比赛分数相同,elasticsearch,kibana,elasticsearch,Kibana" />

elasticsearch Elasticsearch:搜索分数让我困惑。不同级别的比赛分数相同

elasticsearch Elasticsearch:搜索分数让我困惑。不同级别的比赛分数相同,elasticsearch,kibana,elasticsearch,Kibana,要简化: PUT /test/vendors/1 { "type": "doctor", "name": "Ron", "place": "Boston" } PUT /test/vendors/2 { "type": "doctor", "name": "Tom", "place": "Boston" } PUT /test/vendors/3 { "type": "doctor", "name": "Jack", "place": "San

要简化:

PUT /test/vendors/1
{
  "type": "doctor",
  "name": "Ron",
  "place": "Boston"  
}

PUT /test/vendors/2
{
  "type": "doctor",
  "name": "Tom",
  "place": "Boston"  

}

PUT /test/vendors/3
{
  "type": "doctor",
  "name": "Jack",
  "place": "San Fran"  

}
然后搜索:

GET /test/_search
{
  "query": {
    "multi_match" : {
      "query":    "doctor in Boston", 
      "fields": [ "type", "place" ] 
    }
  }
}
我明白为什么我得到了在旧金山工作的杰克,因为他也是一名医生。然而,我不明白为什么比赛分数对他来说是一样的。另外两个也与
位置匹配,不是吗?为什么罗恩和汤姆的得分不高

{
  "took": 11,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 0.9245277,
    "hits": [
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "2",
        "_score": 0.9245277,
        "_source": {
          "type": "doctor",
          "name": "Tom",
          "place": "Boston"
        }
      },
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "1",
        "_score": 0.9245277,
        "_source": {
          "type": "doctor",
          "name": "Ron",
          "place": "Boston"
        }
      },
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "3",
        "_score": 0.9245277,
        "_source": {
          "type": "doctor",
          "name": "Jack",
          "place": "San Fran"
        }
      }
    ]
  }
}

有没有办法在搜索关键词较少时强制其得分较低?另外,如果我在这种搜索上走错了方向,并且有更好的模式/方法来做,我希望能被指出正确的方向

您的搜索结构不正确。上面的搜索查询忽略了
place
属性,这就是为什么所有文档的得分都相同(只考虑了
type
属性)。这是因为
工作时是一个嵌套映射,在搜索时应以不同的方式处理


首先,您应该将
处工作定义为嵌套映射(阅读更多)。然后,您必须调整查询以使用该嵌套映射,请参见示例。

有趣。我没有想到。我试试看谢谢!我试着把巢移走。尽管如此,我还是得到了相同的分数(编辑了这篇文章)。我肯定会接受你关于嵌套的建议,但问题仍然是,为什么我的搜索结果得分相似,尽管上一个文档中缺少了“boston”。你确定这能解决问题吗?我的所有成绩都是一样的。指向地点字段仍然是错误的,不是吗?
GET /test/_search
{
  "query": {
    "multi_match" : {
      "query":    "doctor in Boston", 
      "fields": [ "type", "place" ],
      "type": "most_fields" .   <---- I WAS MISSING THIS
    }
  }
}
{
  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 3,
    "max_score": 1.2122098,
    "hits": [
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "2",
        "_score": 1.2122098,
        "_source": {
          "type": "doctor",
          "name": "Tom",
          "place": "Boston"
        }
      },
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "1",
        "_score": 1.2122098,
        "_source": {
          "type": "doctor",
          "name": "Ron",
          "place": "Boston"
        }
      },
      {
        "_index": "test",
        "_type": "vendors",
        "_id": "3",
        "_score": 0.9245277,
        "_source": {
          "type": "doctor",
          "name": "Jack",
          "place": "San Fran"
        }
      }
    ]
  }
}