I am searching on Event
objects in my elasticsearch index using NEST. At its basic level, Event
looks like this:
public class Event
{
public int Id {get; set;}
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)]
public string EventType {get; set;}
}
My search looks like this:
SearchDescriptor<Event> search = new SearchDescriptor<Event>()
.From(0)
.Take(10000)
.QueryRaw(@"{""match_all"": {} }")
.FacetTerm("my_facet", f => f.OnField("eventType"));
var esResults = esClient.Search<Event>(search);
Currently, all of my documents in ES have an eventType
of Test type
, but the facet is returning results for Test
and type
, rather than returning them together.
My understanding is that the Index = FieldIndexOption.NotAnalyzed
is supposed to alleviate this issue, but I am still seeing it. Why is this happening?
Are you sure your index was created with proper mapping?
This code
creates index with following mapping
Your query works fine and returns correct facets:
I have tested it against elasticsearch and NEST 1.5.0.