我正在尝试使用 Solr 在用户搜索中查找完全匹配的类别(e.g. "skinny jeans" in "blue skinny jeans")
。我正在使用以下类型定义:
<fieldType name="subphrase" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer type="index">
<charFilter class="solr.PatternReplaceCharFilterFactory"
pattern="\ "
replacement="_"/>
<tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.ShingleFilterFactory"
outputUnigrams="true"
outputUnigramsIfNoShingles="true"
tokenSeparator="_"
minShingleSize="2"
maxShingleSize="99"/>
</analyzer>
</fieldType>
该类型将索引类别而不进行标记,仅用下划线替换空格。但它将标记化查询并将它们组合在一起(带下划线)。
我想要做的是将查询带状疱疹与索引类别相匹配。在 Solr 分析页面中,我可以看到空格/下划线替换对索引和查询都有效,并且我可以看到查询被正确拼接(下面的屏幕截图):
我的问题是,在 Solr 查询页面中,我看不到正在生成带状疱疹,因此我认为“紧身牛仔裤”类别不匹配,但“牛仔裤”类别匹配:(
这是调试输出:
{
"responseHeader": {
"status": 0,
"QTime": 1,
"params": {
"q": "name:(skinny jeans)",
"indent": "true",
"wt": "json",
"debugQuery": "true",
"_": "1464170217438"
}
},
"response": {
"numFound": 1,
"start": 0,
"docs": [
{
"id": 33,
"name": "jeans",
}
]
},
"debug": {
"rawquerystring": "name:(skinny jeans)",
"querystring": "name:(skinny jeans)",
"parsedquery": "name:skinny name:jeans",
"parsedquery_toString": "name:skinny name:jeans",
"explain": {
"33": "\n2.2143755 = product of:\n 4.428751 = sum of:\n 4.428751 = weight(name:jeans in 54) [DefaultSimilarity], result of:\n 4.428751 = score(doc=54,freq=1.0), product of:\n 0.6709952 = queryWeight, product of:\n 6.600272 = idf(docFreq=1, maxDocs=541)\n 0.10166174 = queryNorm\n 6.600272 = fieldWeight in 54, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 6.600272 = idf(docFreq=1, maxDocs=541)\n 1.0 = fieldNorm(doc=54)\n 0.5 = coord(1/2)\n"
},
"QParser": "LuceneQParser"
}
}
很明显,parsedquery 参数不显示 shingled 查询。我需要做什么才能完成将查询带状疱疹与索引值匹配的过程?我觉得我非常接近解决这个问题。任何建议表示赞赏!