org.apache.lucene.search.spans.SpanContainingQuery Java Examples
The following examples show how to use
org.apache.lucene.search.spans.SpanContainingQuery.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestPayloadScoreQuery.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testSpanContainingQuery() throws Exception { // twenty WITHIN ((one OR hundred) NEAR two)~2 SpanContainingQuery q = new SpanContainingQuery( new SpanNearQuery(new SpanQuery[]{ new SpanOrQuery(new SpanTermQuery(new Term("field", "one")), new SpanTermQuery(new Term("field", "hundred"))), new SpanTermQuery(new Term("field", "two")) }, 2, true), new SpanTermQuery(new Term("field", "twenty")) ); checkQuery(q, new AveragePayloadFunction(), new int[] { 222, 122 }, new float[]{ 4.0f, 3.666666f }); checkQuery(q, new MaxPayloadFunction(), new int[]{ 122, 222 }, new float[]{ 4.0f, 4.0f }); checkQuery(q, new MinPayloadFunction(), new int[]{ 222, 122 }, new float[]{ 4.0f, 2.0f }); }
Example #2
Source File: TestSpanExtractors.java From lucene-solr with Apache License 2.0 | 5 votes |
public void testSpanContains() { Term t1 = new Term("field", "term1"); Term t2 = new Term("field", "term22"); Term t3 = new Term("field", "term333"); SpanContainingQuery swq = new SpanContainingQuery( SpanNearQuery.newOrderedNearQuery("field") .addClause(new SpanTermQuery(t1)) .addClause(new SpanTermQuery(t2)) .build(), new SpanTermQuery(t3)); assertEquals(Collections.singleton(t3), collectTerms(swq)); }
Example #3
Source File: MtasSpanContainingQuery.java From mtas with Apache License 2.0 | 5 votes |
/** * Instantiates a new mtas span containing query. * * @param q1 the q 1 * @param q2 the q 2 */ public MtasSpanContainingQuery(MtasSpanQuery q1, MtasSpanQuery q2) { super(q1 != null ? q1.getMinimumWidth() : null, q1 != null ? q1.getMaximumWidth() : null); if (q2 != null && q2.getMinimumWidth() != null && (this.getMinimumWidth() == null || this.getMinimumWidth() < q2.getMinimumWidth())) { this.setWidth(q2.getMinimumWidth(), this.getMaximumWidth()); } bigQuery = q1; smallQuery = q2; if (bigQuery != null && bigQuery.getField() != null) { field = bigQuery.getField(); } else if (smallQuery != null && smallQuery.getField() != null) { field = smallQuery.getField(); } else { field = null; } if (field != null && bigQuery != null && smallQuery != null) { if (bigQuery.getField() != null && smallQuery.getField() != null) { baseQuery = new SpanContainingQuery(bigQuery, smallQuery); } else { baseQuery = null; } } else { baseQuery = null; } }