protected internal AbstractField(System.String name, Field.Store store, Field.Index index, Field.TermVector termVector) { if (name == null) throw new System.NullReferenceException("name cannot be null"); this.internalName = StringHelper.Intern(name); // field names are interned this.internalIsStored = store.IsStored(); this.internalIsIndexed = index.IsIndexed(); this.internalIsTokenized = index.IsAnalyzed(); this.internalOmitNorms = index.OmitNorms(); this.internalIsBinary = false; SetStoreTermVector(termVector); }
protected internal virtual void SetStoreTermVector(Field.TermVector termVector) { this.storeTermVector = termVector.IsStored(); this.storePositionWithTermVector = termVector.WithPositions(); this.storeOffsetWithTermVector = termVector.WithOffsets(); }
/// <summary> Creates a field for numeric values with the specified /// <c>precisionStep</c>. The instance is not yet initialized with /// a numeric value, before indexing a document containing this field, /// set a value using the various set<em>???</em>Value() methods. /// </summary> /// <param name="name">the field name /// </param> /// <param name="precisionStep">the used <a href="../search/NumericRangeQuery.html#precisionStepDesc">precision step</a> /// </param> /// <param name="store">if the field should be stored in plain text form /// (according to <c>toString(value)</c> of the used data type) /// </param> /// <param name="index">if the field should be indexed using <see cref="NumericTokenStream" /> /// </param> public NumericField(System.String name, int precisionStep, Field.Store store, bool index):base(name, store, index?Field.Index.ANALYZED_NO_NORMS:Field.Index.NO, Field.TermVector.NO) { OmitTermFreqAndPositions = true; tokenStream = new NumericTokenStream(precisionStep); }
/// <summary> Creates a field for numeric values using the default <c>precisionStep</c> /// <see cref="NumericUtils.PRECISION_STEP_DEFAULT" /> (4). The instance is not yet initialized with /// a numeric value, before indexing a document containing this field, /// set a value using the various set<em>???</em>Value() methods. /// </summary> /// <param name="name">the field name /// </param> /// <param name="store">if the field should be stored in plain text form /// (according to <c>toString(value)</c> of the used data type) /// </param> /// <param name="index">if the field should be indexed using <see cref="NumericTokenStream" /> /// </param> public NumericField(System.String name, Field.Store store, bool index):this(name, NumericUtils.PRECISION_STEP_DEFAULT, store, index) { }
public LazyField(FieldsReader enclosingInstance, System.String name, Field.Store store, Field.Index index, Field.TermVector termVector, int toRead, long pointer, bool isBinary, bool isCompressed):base(name, store, index, termVector) { InitBlock(enclosingInstance); this.toRead = toRead; this.pointer = pointer; this.internalIsBinary = isBinary; if (isBinary) internalBinaryLength = toRead; lazy = true; this.isCompressed = isCompressed; }
private void AddField(Document.Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize) { //we have a binary stored field, and it may be compressed if (binary) { int toRead = fieldsStream.ReadVInt(); var b = new byte[toRead]; fieldsStream.ReadBytes(b, 0, b.Length); doc.Add(compressed ? new Field(fi.name, Uncompress(b), Field.Store.YES) : new Field(fi.name, b, Field.Store.YES)); } else { const Field.Store store = Field.Store.YES; Field.Index index = FieldExtensions.ToIndex(fi.isIndexed, tokenize); Field.TermVector termVector = FieldExtensions.ToTermVector(fi.storeTermVector, fi.storeOffsetWithTermVector, fi.storePositionWithTermVector); AbstractField f; if (compressed) { int toRead = fieldsStream.ReadVInt(); var b = new byte[toRead]; fieldsStream.ReadBytes(b, 0, b.Length); f = new Field(fi.name, false, System.Text.Encoding.GetEncoding("UTF-8").GetString(Uncompress(b)), store, index, termVector) {OmitTermFreqAndPositions = fi.omitTermFreqAndPositions, OmitNorms = fi.omitNorms}; } else { f = new Field(fi.name, false, fieldsStream.ReadString(), store, index, termVector) {OmitTermFreqAndPositions = fi.omitTermFreqAndPositions, OmitNorms = fi.omitNorms}; } doc.Add(f); } }