Skip to content
nxtjoe edited this page Mar 17, 2017 · 8 revisions

#Creating an Index Set

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.

##Config

You can see an [example of a configuration document in the sample web project] (https://github.com/Shazwazza/Examine/tree/master/src/Examine.Web.Demo/Web.config#L11)

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>

##Filters

If you want to limit that data that goes into your index, you can specify filters. There are 2 filter types: IndexUserFields and IndexAttributeFields. The difference 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.

This example would mean that only the element values matching element names doc and likes would be included in this index. 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>
  </IndexSet>
</ExamineLuceneIndexSets>

##Field Types & sorting

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
Clone this wiki locally