solr - 带有正斜杠的 Solr 查询不匹配
问题描述
Solr 4.9.1
(无法更新,因为这是一个 Silverstripe 插件)。问题出在前端,但以下问题直接来自 Solr 查询面板。我对 Solr 比较陌生,到目前为止,我一直在研究关于 Tokenizers 和 Filters 的建议(但在这个问题的上下文中无法理解这些建议)和转义(这似乎没有任何作用)
这是我的调试输出示例:
现有文档中的字段值: Across the world - Fly/Sail
查询(前端): Fly/Sail
搜索结果: 0
调试输出:
"rawquerystring": "Fly/Sail",
"querystring": "Fly/Sail",
"parsedquery": "PhraseQuery(_text:\"fly sail fly sail\")",
"parsedquery_toString": "_text:\"fly sail fly sail\"",
"explain": {},
"QParser": "LuceneQParser"
最让我困惑的是为什么在解析查询中加倍?用反斜杠转义正斜杠不会改变任何东西。
如果我搜索"Fly Sail"
,会出现预期的结果。
编辑:我的配置:
<fields>
<field name='_documentid' type='string' indexed='true' stored='true' required='true' />
<field name='ID' type='tint' indexed='true' stored='true' required='true' />
<field name='_text' type='htmltext' indexed='true' stored='true' multiValued='true' />
<field name='VivaTour_TourName' type='text' indexed='true' stored='true' multiValued=''/>
<field name='VivaTour_TourDescription' type='htmltext' indexed='true' stored='true' multiValued=''/>
编辑 2:此搜索的我的分析页面的屏幕截图
解决方案
试试下面fieldType
的你的领域"VivaTour_TourName"
。
<fieldType name="text_wd" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<!-- Splits words based on whitespace characters -->
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<!-- splits words at delimiters based on different arguments -->
<filter class="solr.WordDelimiterGraphFilterFactory" preserveOriginal="1" catenateWords="1"/>
<!-- Transforms text to lower case -->
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
修改后schema.xml
,请重新启动服务器并重新索引数据。
请参阅屏幕截图以供参考。
推荐阅读
- xml - XPath 可以按中间节点对选定节点列表进行分组吗?
- r - 使用 R 将列中的 NA 值替换为数字列表
- android - Jetpack Compose 中 Box 内的组件中的 `fillMaxSize()` 和 `matchParentSize()` 有什么区别?
- prometheus - 如何测试 Victoriametrics 集群的性能?
- file - QtCreator 移动文件
- arrays - XML中的结构数组没有包装节点?
- c - 为什么对来自传感器的数据使用环形缓冲区
- python - 如何在 Flask 应用程序中运行后台控制任务?
- node.js - 节点 setInterval() 太慢了
- python - 获取 subprocess.run 来创建文件?