use of org.apache.lucene.search.WildcardQuery in project lucene-solr by apache.
the class TestStandardQP method testEscapedWildcard.
@Override
public void testEscapedWildcard() throws Exception {
CommonQueryParserConfiguration qp = getParserConfig(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false));
//TODO not correct!!
WildcardQuery q = new WildcardQuery(new Term("field", "foo?ba?r"));
assertEquals(q, getQuery("foo\\?ba?r", qp));
}
use of org.apache.lucene.search.WildcardQuery in project lucene-solr by apache.
the class TestBlockJoinValidation method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
directory = newDirectory();
final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
final IndexWriter indexWriter = new IndexWriter(directory, config);
for (int i = 0; i < AMOUNT_OF_SEGMENTS; i++) {
List<Document> segmentDocs = createDocsForSegment(i);
indexWriter.addDocuments(segmentDocs);
indexWriter.commit();
}
indexReader = DirectoryReader.open(indexWriter);
indexWriter.close();
indexSearcher = new IndexSearcher(indexReader);
parentsFilter = new QueryBitSetProducer(new WildcardQuery(new Term("parent", "*")));
}
use of org.apache.lucene.search.WildcardQuery in project lucene-solr by apache.
the class FieldQueryTest method testHighlightQuery.
public void testHighlightQuery() throws Exception {
makeIndexStrMV();
defgMultiTermQueryTest(new WildcardQuery(new Term(F, "d*g")));
}
use of org.apache.lucene.search.WildcardQuery in project lucene-solr by apache.
the class TestPayloadCheckQuery method testRewrite.
public void testRewrite() throws IOException {
SpanMultiTermQueryWrapper fiv = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "fiv*")));
SpanMultiTermQueryWrapper hund = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "hund*")));
SpanMultiTermQueryWrapper twent = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "twent*")));
SpanMultiTermQueryWrapper nin = new SpanMultiTermQueryWrapper(new WildcardQuery(new Term("field", "nin*")));
SpanNearQuery sq = new SpanNearQuery(new SpanQuery[] { fiv, hund, twent, nin }, 0, true);
List<BytesRef> payloads = new ArrayList<>();
payloads.add(new BytesRef("pos: 0"));
payloads.add(new BytesRef("pos: 1"));
payloads.add(new BytesRef("pos: 2"));
payloads.add(new BytesRef("pos: 3"));
SpanPayloadCheckQuery query = new SpanPayloadCheckQuery(sq, payloads);
// if query wasn't rewritten properly, the query would have failed with "Rewrite first!"
checkHits(query, new int[] { 529 });
}
use of org.apache.lucene.search.WildcardQuery in project elasticsearch by elastic.
the class WildcardQueryBuilder method doToQuery.
@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
MappedFieldType fieldType = context.fieldMapper(fieldName);
Term term;
if (fieldType == null) {
term = new Term(fieldName, BytesRefs.toBytesRef(value));
} else {
Query termQuery = fieldType.termQuery(value, context);
term = MappedFieldType.extractTerm(termQuery);
}
WildcardQuery query = new WildcardQuery(term);
MultiTermQuery.RewriteMethod rewriteMethod = QueryParsers.parseRewriteMethod(rewrite, null);
QueryParsers.setRewriteMethod(query, rewriteMethod);
return query;
}
Aggregations