Skip to content
ExamineX
These docs are for ExamineX 11 · Umbraco 19 (pre-release). For the current release see ExamineX 6–10 · Umbraco 13–18.

Elastic Search APIs

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

ExamineX uses the Elasticsearch .NET client (Elastic.Clients.Elasticsearch) and exposes it as an ElasticsearchClient.

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.Search.IndexAliases.PublishedContent,
out var publishedContentIndex)
|| !(publishedContentIndex is ElasticSearchIndex elasticSearchIndex))
{
throw new InvalidOperationException(
$"No index found with name {Constants.Search.IndexAliases.PublishedContent} or it's type is not {typeof(ElasticSearchIndex)}");
}
ElasticsearchClient elasticClient = elasticSearchIndex.ServiceClient;

If you prefer to work directly with the Elastic Search .NET client APIs to query or update your index data then you can use the exposed ServiceClient 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.

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