# Nested Query Against Different Index Mappings using ignore\_unmapped

**URL:** <https://discuss.elastic.co/t/nested-query-against-different-index-mappings-using-ignore-unmapped/101716>\
**Category:** Elasticsearch\
**Created:** [September 25, 2017, 2:07pm UTC](https://discuss.elastic.co/t/nested-query-against-different-index-mappings-using-ignore-unmapped/101716 "2017-09-25T14:07:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ymao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ymao/32/22489_2.png) [@ymao](https://discuss.elastic.co/u/ymao)\
**Post date:** [September 25, 2017, 2:07pm UTC](https://discuss.elastic.co/t/nested-query-against-different-index-mappings-using-ignore-unmapped/101716/1 "2017-09-25T14:07:39Z")

</div>

Related to this discussion: [Nested query and ignore\_unmapped option problem](https://discuss.elastic.co/t/nested-query-and-ignore-unmapped-option-problem/70693)

Hi,

Using ES 5.6.1, I am trying to make a single query to multiple indices that have slightly different index mappings for a field. One index uses a nested mapping, the other does not. I am using the ignore\_unmapped option in my nested query but am getting failures due to: "[nested] nested object under path [enrichments.urls] is not of nested type"

Here is a partial mapping for index1 (field is not nested):

> ```
> {
> "top_level_field": {
> "properties": {
> "field": {
> "properties": {
> "sub_field": {
> "type": "keyword"
> }
> }
> }
> }
> }
> }
> 
> ```

Here is a partial mapping for index2 (field is nested):

> ```
> {
> "top_level_field": {
> "properties": {
> "field": {
> "type": "nested",
> "properties": {
> "sub_field": {
> "type": "text",
> "analyzer": "custom_analyzer",
> "fields": {
> "analyzed1": {
> "type": "text",
> "analyzer": "custom_analyzer2"
> },
> "analyzed2": {
> "type": "text",
> "analyzer": "another_analyzer"
> }
> }
> }
> }
> }
> }
> }
> }
> 
> ```

Here is a sample query targeting /index1,index2/\_search

> ```
> {
> "query": {
> "bool": {
> "should": [{
> "query_string": {
> "fields": ["top_level_field.field.sub_field"],
> "query": "pizza"
> }
> }, {
> "nested": {
> "path": "top_level_field.field",
> "ignore_unmapped": true,
> "query": {
> "query_string": {
> "fields": ["top_level_field.field.sub_field", "top_level_field.field.sub_field.analyzed1", "top_level_field.field.sub_field.analyzed2"],
> "query": "pizza"
> }
> }
> }
> }]
> }
> }
> }
> 
> ```

According to the docs, it seems like the ignore\_unmapped option should allow this query to successfully execute against two fields in different indices with different mappings. Is that a correct assumption? Is there another way I should be structuring this query?

Thanks

Ying

---

<div class="post-metadata">

**Author:** ![jlapp](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@jlapp](https://discuss.elastic.co/u/jlapp)\
**Post date:** [September 27, 2017, 11:46am UTC](https://discuss.elastic.co/t/nested-query-against-different-index-mappings-using-ignore-unmapped/101716/2 "2017-09-27T11:46:43Z")

</div>

I am seeing the same behavior with 5.6.0. It seems like a bug, unless ignore\_unmapped wasn't intended to handle this case. I have queries structured similarly to those provided by @ymao, although I've tried other variations with no luck.

I guess the bottom line is, should Elasticsearch allow me to query a field across two indices, where in one index the field is nested and in the other it is searchable but not nested?

---

<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:** [October 25, 2017, 11:47am UTC](https://discuss.elastic.co/t/nested-query-against-different-index-mappings-using-ignore-unmapped/101716/3 "2017-10-25T11:47:18Z")

</div>

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