public class TokenSources extends Object
Constructor and Description |
---|
TokenSources() |
Modifier and Type | Method and Description |
---|---|
static TokenStream |
getAnyTokenStream(IndexReader reader,
int docId,
String field,
Analyzer analyzer)
A convenience method that tries a number of approaches to getting a token
stream.
|
static TokenStream |
getAnyTokenStream(IndexReader reader,
int docId,
String field,
Document document,
Analyzer analyzer)
A convenience method that tries to first get a
TokenStreamFromTermVector for the
specified docId, then, falls back to using the passed in
Document to retrieve the TokenStream. |
static TokenStream |
getTokenStream(Document doc,
String field,
Analyzer analyzer) |
static TokenStream |
getTokenStream(IndexReader reader,
int docId,
String field,
Analyzer analyzer) |
static TokenStream |
getTokenStream(String field,
String contents,
Analyzer analyzer) |
static TokenStream |
getTokenStream(Terms tpv)
Returns a token stream generated from a
Terms . |
static TokenStream |
getTokenStream(Terms vector,
boolean tokenPositionsGuaranteedContiguous)
Deprecated.
|
static TokenStream |
getTokenStreamWithOffsets(IndexReader reader,
int docId,
String field)
Returns a
TokenStream with positions and offsets constructed from
field termvectors. |
public static TokenStream getAnyTokenStream(IndexReader reader, int docId, String field, Document document, Analyzer analyzer) throws IOException
TokenStreamFromTermVector
for the
specified docId, then, falls back to using the passed in
Document
to retrieve the TokenStream.
This is useful when you already have the document, but would prefer to use
the vector first.reader
- The IndexReader
to use to try
and get the vector fromdocId
- The docId to retrieve.field
- The field to retrieve on the documentdocument
- The document to fall back onanalyzer
- The analyzer to use for creating the TokenStream if the
vector doesn't existTokenStream
for the
IndexableField
on the
Document
IOException
- if there was an error loadingpublic static TokenStream getAnyTokenStream(IndexReader reader, int docId, String field, Analyzer analyzer) throws IOException
IOException
- If there is a low-level I/O error@Deprecated public static TokenStream getTokenStream(Terms vector, boolean tokenPositionsGuaranteedContiguous) throws IOException
getTokenStream(org.apache.lucene.index.Terms)
now.IOException
public static TokenStream getTokenStream(Terms tpv) throws IOException
Terms
. This
can be used to feed the highlighter with a pre-parsed token
stream. The Terms
must have offsets available. If there are no positions available,
all tokens will have position increments reflecting adjacent tokens, or coincident when terms
share a start offset. If there are stopwords filtered from the index, you probably want to ensure
term vectors have positions so that phrase queries won't match across stopwords.IllegalArgumentException
- if no offsets are availableIOException
public static TokenStream getTokenStreamWithOffsets(IndexReader reader, int docId, String field) throws IOException
TokenStream
with positions and offsets constructed from
field termvectors. If the field has no termvectors or offsets
are not included in the termvector, return null. See getTokenStream(org.apache.lucene.index.Terms)
for an explanation of what happens when positions aren't present.reader
- the IndexReader
to retrieve term vectors fromdocId
- the document to retrieve termvectors forfield
- the field to retrieve termvectors forTokenStream
, or null if offsets are not availableIOException
- If there is a low-level I/O errorgetTokenStream(org.apache.lucene.index.Terms)
public static TokenStream getTokenStream(IndexReader reader, int docId, String field, Analyzer analyzer) throws IOException
IOException
public static TokenStream getTokenStream(Document doc, String field, Analyzer analyzer)
public static TokenStream getTokenStream(String field, String contents, Analyzer analyzer)
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.