如何解决Lucene如何搜索多值字段?
我在 schema.xml 中创建了多值字段:
<field name="path" type="pint" multiValued="true" indexed="true" stored="true"/>
我像这样创建了自己的搜索组件类:
public class CustomComponent extends SearchComponent {
private static final Logger LOG = LoggerFactory.getLogger(CustomComponent.class);
@Override
public void prepare(ResponseBuilder rb) throws IOException {
}
@Override
public void process(ResponseBuilder rb) throws IOException {
LOG.info("CustomComponent running ---");
SolrParams params = rb.req.getParams();
CoreContainer coreContainer = rb.req.getCore().getCoreContainer();
SolrCore solrCore = coreContainer.getCore("example_core");
SolrIndexSearcher categorySearcher = solrCore.getSearcher().get();
IndexReader categoryReader = categorySearcher.getIndexReader();
String pathId = params.get("pathId"); //3
FieldType path = solrCore.getLatestSchema().getField("path").getType();
StandardQueryParser standardQueryParser = new StandardQueryParser();
standardQueryParser.setAnalyzer(path.getQueryAnalyzer());
Query q = standardQueryParser.parse(pathId,"path");
DocList docList = searcher.getDocList(q,null,1000,1000);
LOG.info(docListsize()); // returns 0
//even if there is a document which has field with such value
}
}
这里有什么问题?有没有办法在多值字段上进行搜索?感谢您提前回答。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。