I created multivalued field in schema.xml:
<field name="path" type="pint" multiValued="true" indexed="true" stored="true"/>
I created my own search component class like this:
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, null, 0, 1000, 1000);
LOG.info(docListsize()); // returns 0
//even if there is a document which has field with such value
}
}
What is wrong here? Is there a way to search on multivalued field? Thanks for answer in advance.
question from:
https://stackoverflow.com/questions/65833564/lucene-how-to-search-on-multivalued-field 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…