# Nested query error

**URL:** <https://discuss.elastic.co/t/nested-query-error/64310>\
**Category:** Elasticsearch\
**Created:** [October 28, 2016, 4:34pm UTC](https://discuss.elastic.co/t/nested-query-error/64310 "2016-10-28T16:34:55Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [October 28, 2016, 4:34pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/1 "2016-10-28T16:34:55Z")

</div>

Hi,

I am new to elasticsearch and currently working with nested objects and query...  
I am able to create a nested object but when trying to query it using nested query syntax getting error in field name ... the error says "Field name XXX cannot contain '.' "  
not sure how I can refer a nested object field name in query without "Dot"

also getting error in [elasticSearch.Net](http://elasticSearch.Net) ... when trying to execute query it gives error...  
"[nested] nested object under path [XXX] is not of nested type" ...  
But I can see it on the nested object is marked as nested in index/type...

Followed this link also ... but same error...

> <https://gist.github.com/saiglen/ad8b89836547c7e0ee60>

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 28, 2016, 4:55pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/2 "2016-10-28T16:55:45Z")

</div>

Hi,

1°/ Can you provide the Elasticsearch version you are using ?

2°/ Are you certain that your index "bands" is realy created with the mapping (the query seems ok so...) ?

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [October 31, 2016, 10:47am UTC](https://discuss.elastic.co/t/nested-query-error/64310/3 "2016-10-31T10:47:00Z")

</div>

Am using version 2.4.1 ... [elasticsearch.net](http://elasticsearch.net)  
yes i checked it... it was created successfully .. i followed the instruction given in the link..

Thanks,  
Madhur

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 31, 2016, 11:08am UTC](https://discuss.elastic.co/t/nested-query-error/64310/4 "2016-10-31T11:08:20Z")

</div>

You may have other indices without the same mapping, change query URLS to only search into your /band index:

```
curl -XGET "http://172.16.50.12:9200/bands/_search?pretty=true" -d '
{
    "query" : {
        "nested" : {
            "path" : "xref",
            "query" : {
                "bool" : {
                    "must" : [
                        { "match" : { "xref.name" : "Roger" } }
                    ]
                }
            }
        }
    },
    "fields" : [
        "title"
    ]
}'
```

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [October 31, 2016, 11:28am UTC](https://discuss.elastic.co/t/nested-query-error/64310/5 "2016-10-31T11:28:18Z")

</div>

It is saying  
Field name [[xref.name](http://xref.name)] cannot contain '.'

again same error..

Madhur

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 31, 2016, 12:51pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/6 "2016-10-31T12:51:02Z")

</div>

Can you provide result of :

```
curl 'http://localhost:9200/bands/_mapping?pretty'
```

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [October 31, 2016, 12:55pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/7 "2016-10-31T12:55:03Z")

</div>

{  
"bands": {  
"mappings": {  
"documents": {  
"properties": {  
"fields": {  
"type": "string"  
}-  
"query": {  
"properties": {  
"nested": {  
"properties": {  
"path": {  
"type": "string"  
}-  
"query": {  
"properties": {  
"bool": {  
"properties": {  
"must": {  
"properties": {  
"match": {  
"properties": {  
"name": {  
"type": "string"  
}-  
"xref\_name": {  
"type": "string"  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
}-  
"title": {  
"type": "string"  
}-  
"xref": {  
"type": "nested"  
"properties": {  
"name": {  
"type": "string"  
}-  
}-  
}-  
"year": {  
"type": "integer"  
}-  
}-  
}-  
}-  
}-  
}

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [October 31, 2016, 1:03pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/8 "2016-10-31T13:03:43Z")

</div>

Can you provide a clean JSON of:

```
curl 'http://localhost:9200/bands/_mapping?pretty' 

curl 'http://localhost:9200/bands/documents/_mapping?pretty'
```

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 1, 2016, 10:02am UTC](https://discuss.elastic.co/t/nested-query-error/64310/9 "2016-11-01T10:02:21Z")

</div>

curl '[http://localhost:9200/bands/\_mapping?pretty](http://localhost:9200/bands/_mapping?pretty)'

{  
"bands": {  
"mappings": {  
"documents": {  
"properties": {  
"fields": {  
"type": "string"  
},  
"query": {  
"properties": {  
"nested": {  
"properties": {  
"path": {  
"type": "string"  
},  
"query": {  
"properties": {  
"bool": {  
"properties": {  
"must": {  
"properties": {  
"match": {  
"properties": {  
"name": {  
"type": "string"  
},  
"xref\_name": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
},  
"title": {  
"type": "string"  
},  
"xref": {  
"type": "nested",  
"properties": {  
"name": {  
"type": "string"  
}  
}  
},  
"year": {  
"type": "integer"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 1, 2016, 10:03am UTC](https://discuss.elastic.co/t/nested-query-error/64310/10 "2016-11-01T10:03:06Z")

</div>

curl '[http://localhost:9200/bands/documents/\_mapping?pretty](http://localhost:9200/bands/documents/_mapping?pretty)'

{  
"bands": {  
"mappings": {  
"documents": {  
"properties": {  
"fields": {  
"type": "string"  
},  
"query": {  
"properties": {  
"nested": {  
"properties": {  
"path": {  
"type": "string"  
},  
"query": {  
"properties": {  
"bool": {  
"properties": {  
"must": {  
"properties": {  
"match": {  
"properties": {  
"name": {  
"type": "string"  
},  
"xref\_name": {  
"type": "string"  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}  
},  
"title": {  
"type": "string"  
},  
"xref": {  
"type": "nested",  
"properties": {  
"name": {  
"type": "string"  
}  
}  
},  
"year": {  
"type": "integer"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [November 1, 2016, 5:33pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/11 "2016-11-01T17:33:00Z")

</div>

Your mappings are very strange, I don't understand why you have code looking like queries... I suggest to drop your indices and restart the tutorial from the beginning...

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 2, 2016, 10:55am UTC](https://discuss.elastic.co/t/nested-query-error/64310/12 "2016-11-02T10:55:39Z")

</div>

As suggested I re-created indices , but no luck ... same error...  
just want to know why this is showing error message regarding "." dot in nested query...  
could you please let me know how I can refer nested object property without using Dot "."...

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [November 2, 2016, 11:30am UTC](https://discuss.elastic.co/t/nested-query-error/64310/13 "2016-11-02T11:30:57Z")

</div>

Running this minimal script on a 2.2.0 server : [http://pastebin.com/yzLE1DDc](http://pastebin.com/yzLE1DDc)  
Works perfectly.

You have too refer with a Dot into the name.

@See [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html)

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 2, 2016, 11:33am UTC](https://discuss.elastic.co/t/nested-query-error/64310/14 "2016-11-02T11:33:57Z")

</div>

This is the error I am getting..

## { "error": { "root\_cause": [1] 0: { "type": "mapper\_parsing\_exception" "reason": "Field name [[xref.name](http://xref.name)] cannot contain '.'" }-

"type": "mapper\_parsing\_exception"  
"reason": "Field name [[xref.name](http://xref.name)] cannot contain '.'"  
}-  
"status": 400  
}

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 2, 2016, 11:35am UTC](https://discuss.elastic.co/t/nested-query-error/64310/15 "2016-11-02T11:35:33Z")

</div>

Here is the version info of elastic search...

{  
"name": "Angela Del Toro"  
"cluster\_name": "elasticsearch"  
"cluster\_uuid": "xwJsk3DUT--w9X6le\_BIww"  
"version": {  
"number": "2.4.1"  
"build\_hash": "c67dc32e24162035d18d6fe1e952c4cbcbe79d16"  
"build\_timestamp": "2016-09-27T18:57:55Z"  
"build\_snapshot": false  
"lucene\_version": "5.5.2"  
}-  
"tagline": "You Know, for Search"  
}

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [November 2, 2016, 11:57am UTC](https://discuss.elastic.co/t/nested-query-error/64310/16 "2016-11-02T11:57:38Z")

</div>

Sorry, but I have no more idea...

@dadoonet @warkolm : a suggestion why his nested queries fail on this version ?

---

<div class="post-metadata">

**Author:** ![Madhur\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Madhur\_Bhardwaj](https://discuss.elastic.co/u/Madhur_Bhardwaj)\
**Post date:** [November 2, 2016, 1:03pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/17 "2016-11-02T13:03:01Z")

</div>

No issue...

one more quick quick question... is it possible to get raw query generated by [elasticSearch.Net](http://elasticSearch.Net) library ... "Nest"...  
Am able to get result using rest client but when executing same from Nest getting some error  
"[nested] failed to find nested object under path" ...  
using following code to fire query...

var response = client.Search(s =\> s.Index("contractindex").Query(q =\>q.Nested(c =\> c.Path(p =\> p.Limits)  
.Query(nq =\> nq.Bool(bl =\> bl.Must(mst =\> mst  
.Match(t =\> t.Field( fld =\> fld.Limits.First().LimitType).  
Query("Limit"))))  
))));

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [November 2, 2016, 1:10pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/18 "2016-11-02T13:10:20Z")

</div>

It works when you run the query with Curl command ?

If yes, the problem is in your .Net code... I don't know .Net, but I don't see the pathname in your code.

---

<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:** [July 5, 2017, 10:07pm UTC](https://discuss.elastic.co/t/nested-query-error/64310/19 "2017-07-05T22:07:23Z")

</div>


