IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Nested Query Usage
editNested Query Usage
editNested query allows to query nested objects / docs (see nested mapping). The query is executed against the nested objects / docs as if they were indexed as separate docs (they are, internally) and resulting in the root parent doc (or parent nested mapping).
See the Elasticsearch documentation on nested query for more details.
Fluent DSL example
editq .Nested(c => c .Name("named_query") .Boost(1.1) .InnerHits(i => i.Explain()) .Path(p => p.Tags) .Query(nq => nq .Terms(t => t .Field(f => f.Tags.First().Name) .Terms("lorem", "ipsum") ) ) .IgnoreUnmapped() )
Object Initializer syntax example
editnew NestedQuery { Name = "named_query", Boost = 1.1, InnerHits = new InnerHits { Explain = true }, Path = Field<Project>(p => p.Tags), Query = new TermsQuery { Field = Field<Project>(p => p.Tags.First().Name), Terms = new[] { "lorem", "ipsum" } }, IgnoreUnmapped = true }
Example json output.
{ "nested": { "_name": "named_query", "boost": 1.1, "query": { "terms": { "tags.name": [ "lorem", "ipsum" ] } }, "ignore_unmapped": true, "path": "tags", "inner_hits": { "explain": true } } }