【发布时间】:2015-10-01 07:18:04
【问题描述】:
我对 solr 结果有点困惑。我有索引 query 字段
schema.xml 配置
<field name="question" type="text_query" indexed="true" stored="true" multiValued="false"/>
<fieldType name="text_query" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.EnglishMinimalStemFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
我在 solr 中有以下 6 个文档的索引
[
{
"query": "who is gandhi",
"source": "quora.com",
"id" : 1
},
{
"query": "who is person know as gandhi",
"source": "quora.com",
"id" : 2
},
{
"query": "who is Sachin",
"source": "quora.com",
"id" : 3
},
{
"query": "who is mahatma gandhi",
"source": "quora.com",
"id" : 4
},
{
"query": "who is gandhis",
"source": "quora.com",
"id" : 5
},
{
"query": "who are gandhi brothers",
"source": "quora.com",
"id" : 6
}
]
当我搜索 query:"gandhi" 时,我得到的结果为
来自 solr 的回应
"response": {
"numFound": 4,
"start": 0,
"maxScore": 0.8048013,
"docs": [
{
"query": "who is gandhi btothers",
"id": "6",
"source": "quora.com",
"_version_": 1513810901444067300,
"score": 0.8048013
},
{
"query": "who is person know as gandhi",
"id": "2",
"source": "quora.com",
"_version_": 1513810901436727300,
"score": 0.643841
},
{
"query": "who is gandhi",
"id": "1",
"source": "quora.com",
"_version_": 1513810901428338700,
"score": 0.5945348
},
{
"query": "who is mahatma gandhi",
"id": "4",
"source": "quora.com",
"_version_": 1513810901431484400,
"score": 0.37158427
}
]
}
根据我的配置,我认为我应该得到低于 maxscore
的结果{
"query": "who is gandhi",
"id": "1",
"source": "quora.com",
"_version_": 1513810901428338700,
"score": 0.5945348
}
解释调试中的字段
"explain": {
"1": "\n0.5945348 = (MATCH) weight(query:gandhi in 0) [DefaultSimilarity], result of:\n 0.5945348 = score(doc=0,freq=1.0), product of:\n 0.99999994 = queryWeight, product of:\n 0.5945349 = idf(docFreq=2, maxDocs=2)\n 1.681987 = queryNorm\n 0.5945349 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 0.5945349 = idf(docFreq=2, maxDocs=2)\n 1.0 = fieldNorm(doc=0)\n",
"2": "\n0.643841 = (MATCH) weight(query:gandhi in 0) [DefaultSimilarity], result of:\n 0.643841 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.5 = fieldNorm(doc=0)\n",
"4": "\n0.37158427 = (MATCH) weight(query:gandhi in 1) [DefaultSimilarity], result of:\n 0.37158427 = score(doc=1,freq=1.0), product of:\n 0.99999994 = queryWeight, product of:\n 0.5945349 = idf(docFreq=2, maxDocs=2)\n 1.681987 = queryNorm\n 0.3715843 = fieldWeight in 1, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 0.5945349 = idf(docFreq=2, maxDocs=2)\n 0.625 = fieldNorm(doc=1)\n",
"6": "\n0.8048013 = (MATCH) weight(query:gandhi in 3) [DefaultSimilarity], result of:\n 0.8048013 = fieldWeight in 3, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.625 = fieldNorm(doc=3)\n"
}
但结果有所不同。为什么会这样?帮助赞赏:)
【问题讨论】:
-
您为什么这么认为,因为该文档的 id=1?
-
no id 仅由我给出..我认为是因为查询仅包含三个单词,所以不匹配的单词较少
-
嘿,我索引了您提供的六条记录,并获得了
{ "query": "who is gandhi", "source": "quora.com", "id": 1, "score": 0.73895097 },作为第一个具有高相似度分数的记录。你用的是什么solr版本?我已经在 5.2.1 上测试过了。 -
@YoungHobbit 你使用的配置是一样的吗?
-
stopword.txt 的内容是什么。以前我用 text_general 类型检查过。
标签: solr