Skip to content
Shannon Deminick edited this page Jul 21, 2020 · 7 revisions

*** 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.


Creating an Indexer

What is an indexer?

The standard approach to creating a custom indexer provider is to inherit from the

Examine.LuceneEngine.Providers.LuceneIndexer

which will provide all of the functionality for writing and working with the Lucene index. It has all the methods which you need to implement to provide the operations such as:

  • Adding nodes to the index
  • Removing nodes from the index
  • Rebuilding the index based on a data source

It also has all the events which can/ should be used for the different points of the indexers life cycle.

Implementation

The methods that need to be implemented are:

protected abstract void PerformIndexAll(string type);
protected abstract void PerformIndexRebuild();

These methods are intended for your implementation to read from a data source and add each resulting item to the index using the abstract classes API.

Another implementation that is shipped with the Examine core is:

Examine.LuceneEngine.Providers.SimpleDataIndexer

You can use this implementation to index data from a specified data source so all you would need to do is declare a data source. The easiest way to see how this works and can be implemented is to downlaod the "Examine web application demo for custom db indexing" on the Downloads page.

Config

Once you've created your indexer implementation you'll need to add it to config:

<Examine>
  <providers>
    <ExamineIndexProviders>
	  <add name="myIndexer" type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine" dataService="Examine.Web.Demo.TableDirectReaderDataService, Examine.Web.Demo" indexTypes="TestType" />
	</ExamineIndexProviders>
  </providers>    
</Examine>
Clone this wiki locally