1

即使我使用“解释”,我也不了解我的查询是如何评分的。分数似乎是任意的——也许对 Elastic Search 有更好理解的人可以向我解释一下?

我的设置和映射如下所示(我使用的是轮胎):

  settings :analysis => {
            :analyzer => {
              :nickname => {
                :tokenizer => "standard",
                :filter    => ["stop", "nickname_words", "lowercase"],
                :type      => "custom"
              }
            },
            :filter => {
              :nickname_words  => { :type => "word_delimiter", :generate_word_parts => true, :generate_number_parts => true,
                                    :split_on_numerics => true, :split_on_case_change => true, :catenate_words => true,
                                    :preserve_original => true }
            }
          }

  mapping do
    indexes :id,       :type => "integer", :index => :not_analyzed, :include_in_all => false
    indexes :nickname, :type => "string",  :index_analyzer => :nickname, :search_analyzer => :standard, :include_in_all => true
  end

例如,如果我对“test”的昵称进行匹配查询,我会返回:

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 3,
    "max_score" : 1.0,
    "hits" : [ {
      "_shard" : 2,
      "_node" : "YE2N_R_qRMaXmcdobaMkWQ",
      "_index" : "users",
      "_type" : "user",
      "_id" : "6",
      "_score" : 1.0, "_source" : {"id":6,"nickname":"test242424"},
      "_explanation" : {
        "value" : 1.0,
        "description" : "weight(nickname:test in 0) [PerFieldSimilarity], result of:",
        "details" : [ {
          "value" : 1.0,
          "description" : "fieldWeight in 0, product of:",
          "details" : [ {
            "value" : 1.0,
            "description" : "tf(freq=1.0), with freq of:",
            "details" : [ {
              "value" : 1.0,
              "description" : "termFreq=1.0"
            } ]
          }, {
            "value" : 1.0,
            "description" : "idf(docFreq=1, maxDocs=2)"
          }, {
            "value" : 1.0,
            "description" : "fieldNorm(doc=0)"
          } ]
        } ]
      }
    }, {
      "_shard" : 3,
      "_node" : "YE2N_R_qRMaXmcdobaMkWQ",
      "_index" : "users",
      "_type" : "user",
      "_id" : "7",
      "_score" : 1.0, "_source" : {"id":7,"nickname":"SecondTest353535"},
      "_explanation" : {
        "value" : 1.0,
        "description" : "weight(nickname:test in 0) [PerFieldSimilarity], result of:",
        "details" : [ {
          "value" : 1.0,
          "description" : "fieldWeight in 0, product of:",
          "details" : [ {
            "value" : 1.0,
            "description" : "tf(freq=1.0), with freq of:",
            "details" : [ {
              "value" : 1.0,
              "description" : "termFreq=1.0"
            } ]
          }, {
            "value" : 1.0,
            "description" : "idf(docFreq=1, maxDocs=2)"
          }, {
            "value" : 1.0,
            "description" : "fieldNorm(doc=0)"
          } ]
        } ]
      }
    }, {
      "_shard" : 0,
      "_node" : "YE2N_R_qRMaXmcdobaMkWQ",
      "_index" : "users",
      "_type" : "user",
      "_id" : "4",
      "_score" : 0.30685282, "_source" : {"id":4,"nickname":"test123"},
      "_explanation" : {
        "value" : 0.30685282,
        "description" : "weight(nickname:test in 0) [PerFieldSimilarity], result of:",
        "details" : [ {
          "value" : 0.30685282,
          "description" : "fieldWeight in 0, product of:",
          "details" : [ {
            "value" : 1.0,
            "description" : "tf(freq=1.0), with freq of:",
            "details" : [ {
              "value" : 1.0,
              "description" : "termFreq=1.0"
            } ]
          }, {
            "value" : 0.30685282,
            "description" : "idf(docFreq=1, maxDocs=1)"
          }, {
            "value" : 1.0,
            "description" : "fieldNorm(doc=0)"
          } ]
        } ]
      }
    } ]
  }
}                                                                   

我希望 test123 出现在 SecondTest353535 和 test24242424 之前,因为它最相似。

为什么会这样?

4

0 回答 0