Using Elastic Search APIs directly

You can of course go beyond the normal behavior and APIs that come with Examine. If you want to use the NEST Elastic Search APIs directly you can access them directly from ExamineX. The Elastic Search services are exposed as properties of ExamineX.ElasticSearch.ElasticSearchIndex.

NOTE: Because of the dynamic nature of Umbraco data, all data stored in the Elastic Search indexes created by ExamineX are not strongly typed and are based off of the dictionary based model ExamineX.ElasticSearch.Document.

To access these services you will need to cast the IIndex reference from IExamineManager to ElasticSearchIndex.

Example:

if (!_examineManager.TryGetIndex(
    Constants.UmbracoIndexes.ExternalIndexName, 
    out var externalIndex)
    || !(externalIndex is ElasticSearchIndex elasticSearchIndex))
{
    throw new InvalidOperationException(
        $"No index found with name {Constants.UmbracoIndexes.ExternalIndexName} or it's type is not {typeof(ElasticSearchIndex)}");
}

IElasticClient elasticClient = elasticSearchIndex.ServiceClient;

Querying/Indexing

If you prefer to work directly with NEST Elastic Search APIs to query or update your index data then you can use the exposed ISearchIndexClient mentioned above. Since Elastic Search has many more features than are exposed by Examine/ExamineX you will have to use these APIs to access those advanced features.

One of the great benefits of ExamineX is that it will ensure your indexes are always in sync with your Umbraco data without you having to do anything but also giving you the flexibility to use Elastic Search directly.

Index modifications

It is possible to completely configure and modify the Elastic Search indexes created with ExamineX using the IElasticClient however it is advised to not remove any indexes, fields, field mappings or custom analyzers created with ExamineX otherwise unexpected errors may result.