Use a ConstantScoreQuery. It won't affect it score, and is the same was as the fq parameter is implemented in Solr:
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException {
// SolrRequestInfo reqInfo = SolrRequestInfo.getRequestInfo();
if (!(searcher instanceof SolrIndexSearcher)) {
// delete-by-query won't have SolrIndexSearcher
return new BoostQuery(new ConstantScoreQuery(q), 0).createWeight(searcher, scoreMode, 1f);
}
SolrIndexSearcher solrSearcher = (SolrIndexSearcher)searcher;
DocSet docs = solrSearcher.getDocSet(q);
// reqInfo.addCloseHook(docs); // needed for off-heap refcounting
return new BoostQuery(new SolrConstantScoreQuery(docs.getTopFilter()), 0).createWeight(searcher, scoreMode, 1f);
}
fq=section:1as the input to a query parser directly in Lucene?fqis Solr syntax, it's not directly related to Lucene. Add your actual code and what you're trying to do - if you just want to add an extra condition forsection:1, you can add ` AND section:1` to your query, To replicate thefqbehavior to not affect score, use aConstantScoreQuery.(name: abc OR name: xyz) AND id:(1 2 3 ). I pass this to StandardQueryParser and it parses to 2 bool queries. Bool query 1 is a "should" clause for the OR condition above. The second bool query also gets translated to a "should" clause for id part of it. But what I want to do is "filter" for id query not "should" as "filter" performs better than "should"