use of org.apache.lucene.search.MatchNoDocsQuery in project lucene-solr by apache.
the class TestMultiFieldQPHelper method assertStopQueryIsMatchNoDocsQuery.
// verify parsing of query using a stopping analyzer
private void assertStopQueryIsMatchNoDocsQuery(String qtxt) throws Exception {
String[] fields = { "b", "t" };
Occur[] occur = { Occur.SHOULD, Occur.SHOULD };
TestQPHelper.QPTestAnalyzer a = new TestQPHelper.QPTestAnalyzer();
StandardQueryParser mfqp = new StandardQueryParser();
mfqp.setMultiFields(fields);
mfqp.setAnalyzer(a);
Query q = mfqp.parse(qtxt, null);
assertTrue(q instanceof MatchNoDocsQuery);
}
use of org.apache.lucene.search.MatchNoDocsQuery in project lucene-solr by apache.
the class GraphTermsQParserPlugin method createParser.
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
return new QParser(qstr, localParams, params, req) {
@Override
public Query parse() throws SyntaxError {
String fname = localParams.get(QueryParsing.F);
FieldType ft = req.getSchema().getFieldTypeNoEx(fname);
int maxDocFreq = localParams.getInt("maxDocFreq", Integer.MAX_VALUE);
//never null
String qstr = localParams.get(QueryParsing.V);
if (qstr.length() == 0) {
return new MatchNoDocsQuery();
}
final String[] splitVals = qstr.split(",");
Term[] terms = new Term[splitVals.length];
BytesRefBuilder term = new BytesRefBuilder();
for (int i = 0; i < splitVals.length; i++) {
String stringVal = splitVals[i].trim();
if (ft != null) {
ft.readableToIndexed(stringVal, term);
} else {
term.copyChars(stringVal);
}
BytesRef ref = term.toBytesRef();
terms[i] = new Term(fname, ref);
}
ArrayUtil.timSort(terms);
return new ConstantScoreQuery(new GraphTermsQuery(fname, terms, maxDocFreq));
}
};
}
Aggregations