I've set my one field to nested type. I followed as per this documentation https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-joining-queries.html#java-query-dsl-nested-query
Below is the snippet
"price":{
"type":"nested",
"properties":{
"activity_price":{
"type":"double"
},
"multimedia_price":{
"type":"double"
},
"transportation_price":{
"type":"double"
}
}
}
While performing query
QueryBuilders.nestedQuery("price", QueryBuilders.boolQuery()
.must(QueryBuilders.matchQuery("price.activity_price", price)),
ScoreMode.Max);
I get [nested] nested object under path [price] is not of nested type.
I'm using Elasticsearch 5.1.2
I've three files to create index,mappings and to populate data:- mapping.json
{
"settings":{
"number_of_shards":1,
"number_of_replicas":0
},
"mappings":{
"test_type_table":{
"price":{
"type":"nested",
"properties":{
"activity_price":{
"type":"double"
},
"multimedia_price":{
"type":"double"
},
"transportation_price":{
"type":"double"
}
}
}
}
}
}
data.json
{ "index" : { "_index" : "test_index", "_type" : "test_type_table", "_id" : "1" } }
{"price": [{"activity_price":"100.00","multimedia_price":"10","transporation_price":"10"}]}
and setup.json
curl -XPOST http://localhost:9200/test_index -d @mapping.json
curl -s -XPOST http://localhost:9200/_bulk --data-binary @data.json
curl -XGET localhost:9200/your_index?pricefield is notnested, so you must have done something wrong when creating the index. You need to wipe it and create it again with your mapping.-XPUTinstead of-XPOST, your index probably wasn't created with your first command, but only when sending the second bulk command