Class DocumentExtensions
LUCENENET specific extensions to the Document class.
Inheritance
Namespace: Lucene.Net.Documents.Extensions
Assembly: Lucene.Net.dll
Syntax
public static class DocumentExtensions : object
Methods
| Improve this Doc View SourceAddBinaryDocValuesField(Document, String, BytesRef)
Adds a new Binary
Declaration
public static BinaryDocValuesField AddBinaryDocValuesField(this Document document, string name, BytesRef value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Bytes |
value | binary content |
Returns
Type | Description |
---|---|
Binary |
The field that was added to this Document. |
AddDoubleDocValuesField(Document, String, Double)
Adds a new Double
Declaration
public static DoubleDocValuesField AddDoubleDocValuesField(this Document document, string name, double value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 64-bit double value |
Returns
Type | Description |
---|---|
Double |
The field that was added to this Document. |
Remarks
Syntactic sugar for encoding doubles as Numeric
Per-document double values can be retrieved via
Get
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.
AddDoubleField(Document, String, Double, Field.Store)
Adds a stored or un-stored DoubleprecisionStep
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. |
name | field name |
System. |
value | 64-bit |
Field. |
stored | YES if the content should also be stored |
Returns
Type | Description |
---|---|
Double |
The field that was added to this Document. |
AddDoubleField(Document, String, Double, FieldType)
Adds a stored or un-stored Double
Expert: allows you to customize the Field
Declaration
public static DoubleField AddDoubleField(this Document document, string name, double value, FieldType type)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 64-bit double value |
Field |
type | customized field type: must have Numeric |
Returns
Type | Description |
---|---|
Double |
The field that was added to this Document. |
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. |
name | field name |
System. |
value | 32-bit |
Field. |
stored | YES if the content should also be stored |
Returns
Type | Description |
---|---|
Int32Field | The field that was added to this Document. |
AddInt32Field(Document, String, Int32, FieldType)
Adds a stored or un-stored Int32Field with the provided value.
Expert: allows you to customize the
Field
Declaration
public static Int32Field AddInt32Field(this Document document, string name, int value, FieldType type)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 32-bit |
Field |
type | customized field type: must have Numeric |
Returns
Type | Description |
---|---|
Int32Field | The field that was added to this Document. |
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. |
name | field name |
System. |
value | 64-bit |
Field. |
stored | YES if the content should also be stored |
Returns
Type | Description |
---|---|
Int64Field | The field that was added to this Document. |
AddInt64Field(Document, String, Int64, FieldType)
Adds a stored or un-stored Int64Field with the provided value.
Expert: allows you to customize the Field
Declaration
public static Int64Field AddInt64Field(this Document document, string name, long value, FieldType type)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 64-bit |
Field |
type | customized field type: must have Numeric |
Returns
Type | Description |
---|---|
Int64Field | The field that was added to this Document. |
AddNumericDocValuesField(Document, String, Int64)
Adds a new Numeric
Declaration
public static NumericDocValuesField AddNumericDocValuesField(this Document document, string name, long value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 64-bit |
Returns
Type | Description |
---|---|
Numeric |
The field that was added to this Document. |
Remarks
If you also need to store the value, you should add a
separate Stored
AddSingleDocValuesField(Document, String, Single)
Adds a new Single
Declaration
public static SingleDocValuesField AddSingleDocValuesField(this Document document, string name, float value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 32-bit |
Returns
Type | Description |
---|---|
Single |
The field that was added to this Document. |
AddSingleField(Document, String, Single, Field.Store)
Adds a stored or un-stored SingleprecisionStep
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. |
name | field name |
System. |
value | 32-bit |
Field. |
stored | YES if the content should also be stored |
Returns
Type | Description |
---|---|
Single |
The field that was added to this Document. |
AddSingleField(Document, String, Single, FieldType)
Adds a stored or un-stored Single
Expert: allows you to customize the Field
Declaration
public static SingleField AddSingleField(this Document document, string name, float value, FieldType type)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | 32-bit |
Field |
type | customized field type: must have Numeric |
Returns
Type | Description |
---|---|
Single |
The field that was added to this Document. |
AddSortedDocValuesField(Document, String, BytesRef)
Adds a new Sorted
Declaration
public static SortedDocValuesField AddSortedDocValuesField(this Document document, string name, BytesRef bytes)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Bytes |
bytes | binary content |
Returns
Type | Description |
---|---|
Sorted |
The field that was added to this Document. |
Remarks
If you also need to store the value, you should add a
separate Stored
AddSortedSetDocValuesField(Document, String, BytesRef)
Adds a new Sorted
Declaration
public static SortedSetDocValuesField AddSortedSetDocValuesField(this Document document, string name, BytesRef bytes)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Bytes |
bytes | binary content |
Returns
Type | Description |
---|---|
Sorted |
The field that was added to this Document. |
Remarks
If you also need to store the value, you should add a
separate Stored
AddStoredField(Document, String, BytesRef)
Adds a stored-only field with the given binary value.
NOTE: the provided Bytes
Declaration
public static StoredField AddStoredField(this Document document, string name, BytesRef value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Bytes |
value | Bytes |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
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. |
name | field name |
System. |
value | byte array pointing to binary content (not copied) |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
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. |
name | field name |
System. |
value | |
System. |
offset | starting position of the byte array |
System. |
length | valid length of the byte array |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStoredField(Document, String, Double)
Adds a stored-only field with the given
Declaration
public static StoredField AddStoredField(this Document document, string name, double value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStoredField(Document, String, Int32)
Adds a stored-only field with the given
Declaration
public static StoredField AddStoredField(this Document document, string name, int value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStoredField(Document, String, Int64)
Adds a stored-only field with the given
Declaration
public static StoredField AddStoredField(this Document document, string name, long value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStoredField(Document, String, Single)
Adds a stored-only field with the given
Declaration
public static StoredField AddStoredField(this Document document, string name, float value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStoredField(Document, String, String)
Adds a stored-only field with the given
Declaration
public static StoredField AddStoredField(this Document document, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value |
Returns
Type | Description |
---|---|
Stored |
The field that was added to this Document. |
AddStringField(Document, String, String, Field.Store)
Adds a new String
Declaration
public static StringField AddStringField(this Document document, string name, string value, Field.Store stored)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | |
Field. |
stored | YES if the content should also be stored |
Returns
Type | Description |
---|---|
String |
The field that was added to this Document. |
AddTextField(Document, String, TokenStream)
Adds a new un-stored Text
Declaration
public static TextField AddTextField(this Document document, string name, TokenStream stream)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Token |
stream | Token |
Returns
| Improve this Doc View SourceAddTextField(Document, String, String, Field.Store)
Adds a new Text
Declaration
public static TextField AddTextField(this Document document, string name, string value, Field.Store stored)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
System. |
value | |
Field. |
stored | YES if the content should also be stored |
Returns
| Improve this Doc View SourceAddTextField(Document, String, TextReader)
Adds a new un-stored Text
Declaration
public static TextField AddTextField(this Document document, string name, TextReader reader)
Parameters
Type | Name | Description |
---|---|---|
Document | document | This Document. |
System. |
name | field name |
Text |
reader |
Returns
| Improve this Doc View SourceGetField<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
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
GetFields<T>(Document, String)
Returns an array of IIndexableT
.
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
Returns
Type | Description |
---|---|
T[] | a Indexable |
Type Parameters
Name | Description |
---|---|
T |