Class TermVectorsFields
- java.lang.Object
-
- org.apache.lucene.index.Fields
-
- org.elasticsearch.action.termvectors.TermVectorsFields
-
public final class TermVectorsFields extends Fields
This class represents the result of aTermVectorsRequest. It works exactly like theFieldsclass except for one thing: It can return offsets and payloads even if positions are not present. You must call nextPosition() anyway to move the counter although this method only returns-1,, if no positions were returned by theTermVectorsRequest.The data is stored in two byte arrays (
headerRefandtermVectors, bothBytesRef) that have the following format:headerRef: Stores offsets per field in thetermVectorsarray and some header information asBytesRef. Format is- String : "TV"
- vint: version (=-1)
- boolean: hasTermStatistics (are the term statistics stored?)
- boolean: hasFieldStatitsics (are the field statistics stored?)
- vint: number of fields
-
- String: field name 1
- vint: offset in
termVectorsfor field 1 - ...
- String: field name last field
- vint: offset in
termVectorsfor last field
termVectors: Stores the actual term vectors as a
BytesRef.Term vectors for each fields are stored in blocks, one for each field. The offsets in
headerRefare used to find where the block for a field starts. Each block begins with a- vint: number of terms
- boolean: positions (has it positions stored?)
- boolean: offsets (has it offsets stored?)
- boolean: payloads (has it payloads stored?)
hasFieldStatisticsis true, seeheaderRef), the following numbers are stored:- vlong: sum of total term frequencies of the field (sumTotalTermFreq)
- vlong: sum of document frequencies for each term (sumDocFreq)
- vint: number of documents in the shard that has an entry for this field (docCount)
After that, for each term it stores
- vint: term lengths
- BytesRef: term name
If term statistics are requested (
hasTermStatisticsis true, seeheaderRef):- vint: document frequency, how often does this term appear in documents?
- vlong: total term frequency. Sum of terms in this field.
- vint: frequency (always returned)
-
- vint: position_1 (if positions)
- vint: startOffset_1 (if offset)
- vint: endOffset_1 (if offset)
- BytesRef: payload_1 (if payloads)
- ...
- vint: endOffset_freqency (if offset)
- BytesRef: payload_freqency (if payloads)
-
-
Field Summary
Fields Modifier and Type Field Description booleanhasScores-
Fields inherited from class org.apache.lucene.index.Fields
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description TermVectorsFields(BytesReference headerRef, BytesReference termVectors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Iterator<String>iterator()Returns an iterator that will step through all fields names.intsize()Returns the number of fields or -1 if the number of distinct field names is unknown.Termsterms(String field)Get theTermsfor this field.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
TermVectorsFields
public TermVectorsFields(BytesReference headerRef, BytesReference termVectors) throws IOException
- Parameters:
headerRef- Stores offsets per field in thetermVectorsand some header information asBytesRef.termVectors- Stores the actual term vectors as aBytesRef.- Throws:
IOException
-
-
Method Detail
-
iterator
public Iterator<String> iterator()
Description copied from class:FieldsReturns an iterator that will step through all fields names. This will not return null.
-
terms
public Terms terms(String field) throws IOException
Description copied from class:FieldsGet theTermsfor this field. This will return null if the field does not exist.- Specified by:
termsin classFields- Throws:
IOException
-
size
public int size()
Description copied from class:FieldsReturns the number of fields or -1 if the number of distinct field names is unknown. If >= 0,Fields.iterator()will return as many field names.
-
-