org.apache.lucene.chunk
Class SpanDechunkingQuery

Object
  extended by Query
      extended by SpanQuery
          extended by SpanDechunkingQuery
All Implemented Interfaces:
Serializable, Cloneable

public class SpanDechunkingQuery
extends SpanQuery

Wraps a SpanQuery, converting chunk spans to look like they're all part of the main document. Uses a DocNumMap to find out the mapping from chunks to the main document. The start and end offsets in each span are then multiplied by the chunk offset times the non-overlapping word count per chunk.

For instance, say that main document 812 has chunks 813-945. And say that the chunk size is 125 words with an overlap of 25. Spans in chunk 813 will have their offsets unchanged; those in 814 will range from 100-199, those in 815 will range from 200-299, etc.

Warning: The spans that result from this query might not be in strict start/end order. Thus, this query is only suitable as a top-level span query, and never as part of another span query.

See Also:
Serialized Form

Field Summary
private  DocNumMap docNumMap
           
private  SpanQuery wrapped
           
 
Constructor Summary
SpanDechunkingQuery(SpanQuery wrap)
          Construct a query that will mark the results of a normal span query.
 
Method Summary
 String getField()
          Returns the name of the field matched by this query.
 Spans getSpans(IndexReader reader, Searcher searcher)
          Expert: Returns the matches for this query in an index.
 Query[] getSubQueries()
           
 Collection getTerms()
          Returns a collection of all terms matched by this query.
 SpanQuery getWrapped()
          Retrieve the SpanQuery being wrapped
 Query rewrite(IndexReader reader)
           
 void setDocNumMap(DocNumMap docNumMap)
          Establish a document number map.
 String toString(String field)
           
 
Methods inherited from class SpanQuery
createWeight, getSpanRecording, setSpanRecording
 
Methods inherited from class Query
clone, combine, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wrapped

private SpanQuery wrapped

docNumMap

private DocNumMap docNumMap
Constructor Detail

SpanDechunkingQuery

public SpanDechunkingQuery(SpanQuery wrap)
Construct a query that will mark the results of a normal span query.

Method Detail

setDocNumMap

public void setDocNumMap(DocNumMap docNumMap)
Establish a document number map. Must be called before getSpans().


getWrapped

public SpanQuery getWrapped()
Retrieve the SpanQuery being wrapped


getField

public String getField()
Description copied from class: SpanQuery
Returns the name of the field matched by this query.

Specified by:
getField in class SpanQuery

getTerms

public Collection getTerms()
Description copied from class: SpanQuery
Returns a collection of all terms matched by this query.

Specified by:
getTerms in class SpanQuery

getSubQueries

public Query[] getSubQueries()

rewrite

public Query rewrite(IndexReader reader)
              throws IOException
Overrides:
rewrite in class Query
Throws:
IOException

toString

public String toString(String field)
Specified by:
toString in class Query

getSpans

public Spans getSpans(IndexReader reader,
                      Searcher searcher)
               throws IOException
Description copied from class: SpanQuery
Expert: Returns the matches for this query in an index. Used internally to search for spans.

Specified by:
getSpans in class SpanQuery
Throws:
IOException