# Elasticsearch nested mapping query not working- JAVA?

**URL:** <https://discuss.elastic.co/t/elasticsearch-nested-mapping-query-not-working-java/73345>\
**Category:** Elasticsearch\
**Created:** [January 31, 2017, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-nested-mapping-query-not-working-java/73345 "2017-01-31T10:40:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohan\_Ghimire](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Mohan\_Ghimire](https://discuss.elastic.co/u/Mohan_Ghimire)\
**Post date:** [January 31, 2017, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-nested-mapping-query-not-working-java/73345/1 "2017-01-31T10:40:34Z")

</div>

I've set my one field to nested type.  
I followed as per this documentation [Joining queries | Java Transport Client (deprecated) [7.17] | Elastic](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

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [January 31, 2017, 11:42am UTC](https://discuss.elastic.co/t/elasticsearch-nested-mapping-query-not-working-java/73345/2 "2017-01-31T11:42:39Z")

</div>

Hi,

can you make sure your mapping is correct? I tried reproducing this with a minimal example (see below). The Query is what you'd get when you send the rest output of your java example to a cluster. This doesn't return the error you described but returns the document:

```auto

PUT index
{
  "mappings": {
    "type": {
      "properties": {
        "name": {
          "type": "keyword"
        },
        "price":{  
           "type":"nested",
           "properties":{  
              "activity_price":{  
                 "type":"double"
              },
              "multimedia_price":{  
                 "type":"double"
              },
              "transportation_price":{  
                 "type":"double"
              }
           }
        }
      }
    }
  }
}

PUT /index/type/1
{
	"name": "Test",
	"price": {
	  "activity_price" : 1.04,
	  "multimedia_price" : 4.546,
	  "transportation_price" : 3.0
	}
}

GET /index/type/_search
{
  "query": {
    "nested": {
      "path": "price",
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "price.activity_price": {
                  "query": 1.04
                }
              }
            }
          ]
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 28, 2017, 11:42am UTC](https://discuss.elastic.co/t/elasticsearch-nested-mapping-query-not-working-java/73345/3 "2017-02-28T11:42:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
