Solr使用PatternTokenizerFactory查询TextField
查询使用PatternTokenizerFactory标记的文本字段时遇到问题 我使用的是Solr版本4.7.2 我的模式如下所示:Solr使用PatternTokenizerFactory查询TextField,solr,textfield,tokenize,Solr,Textfield,Tokenize,查询使用PatternTokenizerFactory标记的文本字段时遇到问题 我使用的是Solr版本4.7.2 我的模式如下所示: <field name="filter_amenity_codes" type="caretDelimited" indexed="true" stored="true" /> ... <fieldType class="solr.TextField" name="caretDelimited"> <analyzer>
<field name="filter_amenity_codes" type="caretDelimited" indexed="true" stored="true" />
...
<fieldType class="solr.TextField" name="caretDelimited">
<analyzer>
<tokenizer class="solr.PatternTokenizerFactory" pattern="\^"/>
</analyzer>
</fieldType>
{
"response": {
"docs": [],
"numFound": 0,
"start": 0
},
"responseHeader": {
"QTime": 2,
"params": {
"_": "1407261941064",
"indent": "true",
"q": "filter_amenity_codes:93",
"wt": "json"
},
"status": 0
}
}
在查询中是否有我未正确执行的操作?或者模式中的“我的字段”设置不正确?您的示例模式可以正常工作,查询也可以正常工作-至少使用Solr 4.9.0 data.json
[
{"id": 123, "filter_amenity_codes":"1^6^7^8^12^13^14"},
{"id": 321, "filter_amenity_codes":"11^16^17^18^112^113^114"}
]
schema.xml(摘录)
然后查询:
http://localhost:8983/solr/collection1/select?
q=filter_amenity_codes:12&wt=json&indent=true
"response":{"numFound":1,"start":0,"docs":[
{
"id":"123",
"filter_amenity_codes":"1^6^7^8^12^13^14",
"_version_":1475631637529100288}]
}]}
结果为:
http://localhost:8983/solr/collection1/select?
q=filter_amenity_codes:12&wt=json&indent=true
"response":{"numFound":1,"start":0,"docs":[
{
"id":"123",
"filter_amenity_codes":"1^6^7^8^12^13^14",
"_version_":1475631637529100288}]
}]}
如果无法获得相同的输出,则导入过程可能会失败。对
*:*
执行查询以查看您是否已为任何值编制了索引,请尝试提交JSON文件以查看该文件是否可搜索(这意味着您的导入失败),并确保正确设置SolrLogging,以便记录任何错误。如果您对注释的查询接近正确,那么您将同时缺少GROUP BY和任何名为FA等的表,因此对此我不能做任何说明 你有带“93”的文件吗?你的例子显示了94。哦,对不起,我在这个例子上犯了错误。是的,我有93个文档。好的-你能添加你正在运行的实际查询吗?当然。我刚刚用回复更新了我上面的帖子。它包含所有参数。在为字段编制索引时,字段末尾是否有空格?太好了!!非常感谢你的帮助!