use of org.apache.solr.search.SolrQueryParser in project lucene-solr by apache.
the class TestReversedWildcardFilterFactory method testQueryParsing.
@Test
public void testQueryParsing() throws Exception {
// add some docs
assertU(adoc("id", "1", "one", "one"));
assertU(adoc("id", "2", "two", "two"));
assertU(adoc("id", "3", "three", "three"));
assertU(adoc("id", "4", "one", "four"));
assertU(adoc("id", "5", "two", "five"));
assertU(adoc("id", "6", "three", "si𝄞x"));
assertU(commit());
assertQ("should have matched", req("+id:1 +one:one"), "//result[@numFound=1]");
assertQ("should have matched", req("+id:4 +one:f*ur"), "//result[@numFound=1]");
assertQ("should have matched", req("+id:6 +three:*si𝄞x"), "//result[@numFound=1]");
SolrQueryRequest req = req();
QParser qparser = QParser.getParser("id:1", req);
SolrQueryParser parserTwo = new SolrQueryParser(qparser, "two");
assertTrue(parserTwo.getAllowLeadingWildcard());
// test conditional reversal
assertTrue(wasReversed(parserTwo, "*hree"));
assertTrue(wasReversed(parserTwo, "t*ree"));
assertTrue(wasReversed(parserTwo, "th*ee"));
assertFalse(wasReversed(parserTwo, "thr*e"));
assertTrue(wasReversed(parserTwo, "?hree"));
assertTrue(wasReversed(parserTwo, "t?ree"));
assertFalse(wasReversed(parserTwo, "th?ee"));
assertFalse(wasReversed(parserTwo, "th?*ee"));
assertFalse(wasReversed(parserTwo, "short*token"));
assertTrue(wasReversed(parserTwo, "ver*longtoken"));
req.close();
}
Aggregations