Show / Hide Table of Contents

    Class DocumentExtensions

    LUCENENET specific extensions to the Document class.

    Inheritance
    System.Object
    DocumentExtensions
    Namespace: Lucene.Net.Documents.Extensions
    Assembly: Lucene.Net.dll
    Syntax
    public static class DocumentExtensions : object

    Methods

    | Improve this Doc View Source

    AddBinaryDocValuesField(Document, String, BytesRef)

    Adds a new BinaryDocValuesField.

    Declaration
    public static BinaryDocValuesField AddBinaryDocValuesField(this Document document, string name, BytesRef value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    BytesRef value

    binary content

    Returns
    Type Description
    BinaryDocValuesField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddDoubleDocValuesField(Document, String, Double)

    Adds a new DoubleDocValuesField field with the specified 64-bit double value

    Declaration
    public static DoubleDocValuesField AddDoubleDocValuesField(this Document document, string name, double value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Double value

    64-bit double value

    Returns
    Type Description
    DoubleDocValuesField

    The field that was added to this Document.

    Remarks

    Syntactic sugar for encoding doubles as NumericDocValues via .

    Per-document double values can be retrieved via GetDoubles(AtomicReader, String, Boolean).

    NOTE: In most all cases this will be rather inefficient, requiring eight bytes per document. Consider encoding double values yourself with only as much precision as you require.

    | Improve this Doc View Source

    AddDoubleField(Document, String, Double, Field.Store)

    Adds a stored or un-stored DoubleField with the provided value and default precisionStep PRECISION_STEP_DEFAULT (4).

    Declaration
    public static DoubleField AddDoubleField(this Document document, string name, double value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Double value

    64-bit value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    DoubleField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddDoubleField(Document, String, Double, FieldType)

    Adds a stored or un-stored DoubleField with the provided value.

    Expert: allows you to customize the FieldType.

    Declaration
    public static DoubleField AddDoubleField(this Document document, string name, double value, FieldType type)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Double value

    64-bit double value

    FieldType type

    customized field type: must have NumericType of DOUBLE.

    Returns
    Type Description
    DoubleField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddInt32Field(Document, String, Int32, Field.Store)

    Adds a stored or un-stored Int32Field with the provided value and default precisionStep PRECISION_STEP_DEFAULT (4).

    Declaration
    public static Int32Field AddInt32Field(this Document document, string name, int value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int32 value

    32-bit value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    Int32Field

    The field that was added to this Document.

    | Improve this Doc View Source

    AddInt32Field(Document, String, Int32, FieldType)

    Adds a stored or un-stored Int32Field with the provided value.

    Expert: allows you to customize the FieldType.

    Declaration
    public static Int32Field AddInt32Field(this Document document, string name, int value, FieldType type)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int32 value

    32-bit value

    FieldType type

    customized field type: must have NumericType of INT32.

    Returns
    Type Description
    Int32Field

    The field that was added to this Document.

    | Improve this Doc View Source

    AddInt64Field(Document, String, Int64, Field.Store)

    Adds a stored or un-stored Int64Field with the provided value and default precisionStep PRECISION_STEP_DEFAULT (4).

    Declaration
    public static Int64Field AddInt64Field(this Document document, string name, long value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int64 value

    64-bit value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    Int64Field

    The field that was added to this Document.

    | Improve this Doc View Source

    AddInt64Field(Document, String, Int64, FieldType)

    Adds a stored or un-stored Int64Field with the provided value.

    Expert: allows you to customize the FieldType.

    Declaration
    public static Int64Field AddInt64Field(this Document document, string name, long value, FieldType type)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int64 value

    64-bit value

    FieldType type

    customized field type: must have NumericType of INT64.

    Returns
    Type Description
    Int64Field

    The field that was added to this Document.

    | Improve this Doc View Source

    AddNumericDocValuesField(Document, String, Int64)

    Adds a new NumericDocValuesField field with the specified 64-bit value

    Declaration
    public static NumericDocValuesField AddNumericDocValuesField(this Document document, string name, long value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int64 value

    64-bit value

    Returns
    Type Description
    NumericDocValuesField

    The field that was added to this Document.

    Remarks

    If you also need to store the value, you should add a separate StoredField instance.

    | Improve this Doc View Source

    AddSingleDocValuesField(Document, String, Single)

    Adds a new SingleDocValuesField field with the specified 32-bit value

    Declaration
    public static SingleDocValuesField AddSingleDocValuesField(this Document document, string name, float value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Single value

    32-bit value

    Returns
    Type Description
    SingleDocValuesField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddSingleField(Document, String, Single, Field.Store)

    Adds a stored or un-stored SingleField with the provided value and default precisionStep PRECISION_STEP_DEFAULT (4).

    Declaration
    public static SingleField AddSingleField(this Document document, string name, float value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Single value

    32-bit value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    SingleField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddSingleField(Document, String, Single, FieldType)

    Adds a stored or un-stored SingleField with the provided value.

    Expert: allows you to customize the FieldType.

    Declaration
    public static SingleField AddSingleField(this Document document, string name, float value, FieldType type)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Single value

    32-bit value

    FieldType type

    customized field type: must have NumericType of SINGLE.

    Returns
    Type Description
    SingleField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddSortedDocValuesField(Document, String, BytesRef)

    Adds a new SortedDocValuesField field.

    Declaration
    public static SortedDocValuesField AddSortedDocValuesField(this Document document, string name, BytesRef bytes)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    BytesRef bytes

    binary content

    Returns
    Type Description
    SortedDocValuesField

    The field that was added to this Document.

    Remarks

    If you also need to store the value, you should add a separate StoredField instance.

    | Improve this Doc View Source

    AddSortedSetDocValuesField(Document, String, BytesRef)

    Adds a new SortedSetDocValuesField field.

    Declaration
    public static SortedSetDocValuesField AddSortedSetDocValuesField(this Document document, string name, BytesRef bytes)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    BytesRef bytes

    binary content

    Returns
    Type Description
    SortedSetDocValuesField

    The field that was added to this Document.

    Remarks

    If you also need to store the value, you should add a separate StoredField instance.

    | Improve this Doc View Source

    AddStoredField(Document, String, BytesRef)

    Adds a stored-only field with the given binary value.

    NOTE: the provided BytesRef is not copied so be sure not to change it until you're done with this field.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, BytesRef value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    BytesRef value

    BytesRef pointing to binary content (not copied)

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Byte[])

    Adds a stored-only field with the given binary value.

    NOTE: the provided byte[] is not copied so be sure not to change it until you're done with this field.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, byte[] value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Byte[] value

    byte array pointing to binary content (not copied)

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Byte[], Int32, Int32)

    Adds a stored-only field with the given binary value.

    NOTE: the provided byte[] is not copied so be sure not to change it until you're done with this field.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, byte[] value, int offset, int length)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Byte[] value

    array pointing to binary content (not copied)

    System.Int32 offset

    starting position of the byte array

    System.Int32 length

    valid length of the byte array

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Double)

    Adds a stored-only field with the given value.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, double value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Double value

    value

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Int32)

    Adds a stored-only field with the given value.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, int value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int32 value

    value

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Int64)

    Adds a stored-only field with the given value.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, long value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Int64 value

    value

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, Single)

    Adds a stored-only field with the given value.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, float value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.Single value

    value

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStoredField(Document, String, String)

    Adds a stored-only field with the given value.

    Declaration
    public static StoredField AddStoredField(this Document document, string name, string value)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.String value

    value

    Returns
    Type Description
    StoredField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddStringField(Document, String, String, Field.Store)

    Adds a new StringField (a field that is indexed but not tokenized)

    Declaration
    public static StringField AddStringField(this Document document, string name, string value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.String value

    value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    StringField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddTextField(Document, String, TokenStream)

    Adds a new un-stored TextField with TokenStream value.

    Declaration
    public static TextField AddTextField(this Document document, string name, TokenStream stream)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    TokenStream stream

    TokenStream value

    Returns
    Type Description
    TextField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddTextField(Document, String, String, Field.Store)

    Adds a new TextField with value.

    Declaration
    public static TextField AddTextField(this Document document, string name, string value, Field.Store stored)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    System.String value

    value

    Field.Store stored

    YES if the content should also be stored

    Returns
    Type Description
    TextField

    The field that was added to this Document.

    | Improve this Doc View Source

    AddTextField(Document, String, TextReader)

    Adds a new un-stored TextField with value.

    Declaration
    public static TextField AddTextField(this Document document, string name, TextReader reader)
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    field name

    TextReader reader

    value

    Returns
    Type Description
    TextField

    The field that was added to this Document.

    | Improve this Doc View Source

    GetField<T>(Document, String)

    Returns a field with the given name if any exist in this document cast to type T, or null. If multiple fields exists with this name, this method returns the first value added.

    Declaration
    public static T GetField<T>(this Document document, string name)
        where T : IIndexableField
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    Field name

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    GetFields<T>(Document, String)

    Returns an array of IIndexableFields with the given name, cast to type T. This method returns an empty array when there are no matching fields. It never returns null.

    Declaration
    public static T[] GetFields<T>(this Document document, string name)
        where T : IIndexableField
    Parameters
    Type Name Description
    Document document

    This Document.

    System.String name

    the name of the field

    Returns
    Type Description
    T[]

    a IndexableField[] array

    Type Parameters
    Name Description
    T
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)