-
-
Notifications
You must be signed in to change notification settings - Fork 123
IndexSet
*** This is Legacy documentation *** here's the links to the current docs:
Tip: There are many unit tests in the source code that can be used as Examples of how to do things. There is also a test web project that has plenty of examples of how to configure indexes and search them.
For each Indexer and Searcher specified you will require an index set. Creating an index set is simply done via configuration and normally is used to just supply the location of where the Lucene index will be stored.
Index sets can also specify what data to store. This is done by filters by including/excluding certain data types, and including only the specified fields. If none of this is specified then all data found in the data source will be indexed. When specifying fields you can also configure what the the data type for a given field is (i.e. date, number, etc...) which affects how it is stored and how it can be searched.
You can see an example of a configuration document in the sample web project
The default index set config below is simple, this has no filters, no field types, etc... this simply means that all of the data that you provide the index will be indexed as-is.
<ExamineLuceneIndexSets>
<IndexSet SetName="myIndexSet" IndexPath="~/App_Data/myIndexSet" />
</ExamineLuceneIndexSets>
If you want to limit that data that goes into your index, you can specify filters. There are 3 filter types: IndexUserFields
, IndexAttributeFields
and IncludeNodeTypes
. The difference between the first two is in how the XML document that is sent to Examine for indexing is structured. The values in the attributes are filtered by IndexAttributeFields
, the values in the elements are filtered by IndexUserFields
. IncludeNodeTypes
lets you limit which document types are indexed. If it's not specified, all document types are indexed.
This example would mean that only the element values matching element names doc
and likes
would be included in this index, and then only for a document type with the alias MyDocumentType
. All values found in attributes would be included too since there is not IndexAttributeFields
filter.
<ExamineLuceneIndexSets>
<IndexSet SetName="documentationIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/documentation/">
<IndexUserFields>
<add Name="doc" />
<add Name="likes" />
</IndexUserFields>
<IncludeNodeTypes>
<add Name="MyDocumentType" />
</IncludeNodeTypes>
</IndexSet>
</ExamineLuceneIndexSets>
Some fields need to be indexed by their native type. By default Examine will index the fields by string, but in some cases these values need to be indexed as numbers, dates, etc... This is required if you want to perform custom queries like Range queries or custom sorting on dates or numbers.
To enable sorting based on this field type, use the EnableSorting='true'
attribute. To specify a custom field data type use the Type='INT'
attribute (where INT is the type that you wish to use)
<ExamineLuceneIndexSets>
<IndexSet SetName="documentationIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/documentation/">
<IndexUserFields>
<add Name="doc"/>
<add Name="likes" Type="INT" EnableSorting="true"/>
</IndexUserFields>
</IndexSet>
</ExamineLuceneIndexSets>
The available types are:
- NUMBER
- INT
- FLOAT
- DOUBLE
- LONG
- DATE
- DATETIME
- DATE.YEAR
- DATE.MONTH
- DATE.DAY
- DATE.HOUR
- DATE.MINUTE