| PayloadSpans | WARNING: The status of the Payloads feature is experimental. | code | html |
| SpanQuery | Base class for span-based queries. | code | html |
| Spans | Expert: an enumeration of span matches. | code | html |
| FieldMaskingSpanQuery | Wrapper to allow SpanQuery objects participate in composite single-field SpanQueries by 'lying' about their search field. |
code | html |
| NearSpans | Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | code | html |
| NearSpans.CellQueue | code | html | |
| NearSpans.SpansCell | Wraps a Spans, and can be used to form a linked list. | code | html |
| NearSpansOrdered | A Spans that is formed from the ordered subspans of a SpanNearQuery where the subspans do not overlap and have a maximum slop between them. | code | html |
| NearSpansUnordered | Similar to NearSpansOrdered , but for the unordered case. | code | html |
| NearSpansUnordered.CellQueue | code | html | |
| NearSpansUnordered.SpansCell | Wraps a Spans, and can be used to form a linked list. | code | html |
| SpanFirstQuery | Matches spans near the beginning of a field. | code | html |
| SpanNearQuery | Matches spans which are near one another. | code | html |
| SpanNotQuery | Removes matches which overlap with another SpanQuery. | code | html |
| SpanOrQuery | Matches the union of its clauses. | code | html |
| SpanOrQuery.SpanQueue | code | html | |
| SpanScorer | Public for extension only. | code | html |
| SpanTermQuery | Matches spans containing a term. | code | html |
| SpanWeight | Expert-only. Public for use by other weight implementations | code | html |
| TermSpans | Expert: Public for extension only | code | html |
| TestBasics | Tests basic search capabilities. | code | html |
| TestSpans | Copyright 2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. | code | html |
A span is a <doc,startPosition,endPosition> tuple.
The following span query operators are implemented:
q whose end position is less than
n. This can be used to constrain matches to the first
part of the document.For example, a span query which matches "John Kerry" within ten words of "George Bush" within the first 100 words of the document could be constructed with:
SpanQuery john = new SpanTermQuery(new Term("content", "john"));
SpanQuery kerry = new SpanTermQuery(new Term("content", "kerry"));
SpanQuery george = new SpanTermQuery(new Term("content", "george"));
SpanQuery bush = new SpanTermQuery(new Term("content", "bush"));
SpanQuery johnKerry =
new SpanNearQuery(new SpanQuery[] {john, kerry}, 0, true);
SpanQuery georgeBush =
new SpanNearQuery(new SpanQuery[] {george, bush}, 0, true);
SpanQuery johnKerryNearGeorgeBush =
new SpanNearQuery(new SpanQuery[] {johnKerry, georgeBush}, 10, false);
SpanQuery johnKerryNearGeorgeBushAtStart =
new SpanFirstQuery(johnKerryNearGeorgeBush, 100);
Span queries may be freely intermixed with other Lucene queries. So, for example, the above query can be restricted to documents which also use the word "iraq" with:
Query query = new BooleanQuery();
query.add(johnKerryNearGeorgeBushAtStart, true, false);
query.add(new TermQuery("content", "iraq"), true, false);