I am using Olivere flexible Go library to run Elastic queries - https://godoc.org/github.com/olivere/elastic#NestedQuery
The data I'm trying to execute is as follows:
"_source": { "field1": "randVal1", "field2": "randVal2", "nestedfield": { "ind1": "val1" } }
I am trying to run a query on nestedfield by calling NestedQuery from the Elastic Go library like this:
aquery := elastic.NewTermQuery("ind1", "val1") query := elastic.NestedQuery("nestedfield", aquery)
But I get an error message:
too many arguments to convert to NestedQuery
I am trying to get all documents where ind1 of nestedfield is val1 . Thank you for your help in building this request.
EDIT:
I changed it to NewNestedQuery and now it does not give this error. However, it does not return any results, even though this document exists in the index, and I can request non-nested fields.
I tried this:
aquery := elastic.NewTermQuery("ind1", "val1") query := elastic.NewNestedQuery("nestedfield", aquery)
And this:
query := elastic.NewNestedQuery("nestedfield", elastic.NewMatchQuery("nestedfield.ind1", "val1"))
But they both give 0 results. Any idea what I'm doing wrong?
EDIT No. 2
Display:
"field1": { "type": "string" }, "field2": { "type": "string" }, "nestedfield": { "type": "nested" }
What ultimately happened:
query := elastic.NewMatchQuery("nestedfield.ind1", "val1")
I managed to add additional fields to the "nested field" and make such requests as:
query := elastic.NewBoolQuery().Filter(elastic.NewMatchQuery("nestedfield.ind1", "val1"), elastic.NewMatchQuery("nestedfield.ind2", "val2"))