# Reindexing Elasticsearch creates a mapping which cannot be searched

**URL:** <https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559>\
**Category:** Elasticsearch\
**Created:** [October 9, 2020, 11:47am UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559 "2020-10-09T11:47:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leon_roy/32/76897_2.png) [@Leon\_Roy](https://discuss.elastic.co/u/Leon_Roy)\
**Post date:** [October 9, 2020, 11:47am UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559/1 "2020-10-09T11:47:45Z")

</div>

Bit of an odd one or I'm missing something.

We reindexed an AWS Elasticsearch index from `old_index` to `new_index` but for some reason searches on the new index return no results.

The steps we took are:

**Reindex**

```auto
curl -H 'Content-Type: application/json' -XPOST 'hostname/_reindex' -d '
{
  "source": {
    "index": "old_index"
  },
  "dest": {
    "index": "new_index"
  }
}'

```

The mapping of the old index is:

```auto
{
    "old_index": {
        "mappings": {
            "share": {
                "dynamic": "false",
                "properties": {
                    "creationDate": {
                        "type": "long"
                    },
                    "eventId": {
                        "type": "keyword"
                    },
                    "title": {
                        "type": "text"
                    },
                    "userId": {
                        "type": "keyword"
                    }
                }
            }
        }
    }
}

```

The mapping of the new index is:

```auto
{
    "new_index": {
        "mappings": {
            "share": {
                "properties": {
                    "age": {
                        "type": "long"
                    },
                    "creationDate": {
                        "type": "long"
                    },
                    "eventId": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "title": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "userId": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    }
                }
            }
        }
    }
}

```

If we do a `match_all` query on either index both report an identical number of documents. However if we do a `filter` `query` like so:

```auto
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "eventId": {
              "value": "abc123"
            }
          }
        }
      ]
    }
  }
}

```

Only the `old_index` returns a match, the new index does not despite containing a document with a corresponding `eventId`.

Questions are:

1. Where is the `age` property in the `new_index` coming from?
2. Why is reindexing changing the mapping?
3. Is there something in the mapping of `new_index` which is preventing our filter `query` above from working?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 9, 2020, 2:31pm UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559/2 "2020-10-09T14:31:45Z")

</div>

Reindex just reads documents from a source and send the Json to a destination.

If you don't create a mapping, elasticsearch generates a default mapping for you. That's what happened.

---

<div class="post-metadata">

**Author:** ![Leon\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leon_roy/32/76897_2.png) [@Leon\_Roy](https://discuss.elastic.co/u/Leon_Roy)\
**Post date:** [October 9, 2020, 5:28pm UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559/3 "2020-10-09T17:28:42Z")

</div>

Thanks based upon the above auto generated mapping for `new_index` shouldn't my above filter on term `eventId` returned a matching document?

Because it did for `old_index` but not the new one.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 9, 2020, 7:14pm UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559/4 "2020-10-09T19:14:00Z")

</div>

I don't think so.  
But if you search on `eventId.keyword` field, it should match.

---

<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:** [November 6, 2020, 7:14pm UTC](https://discuss.elastic.co/t/reindexing-elasticsearch-creates-a-mapping-which-cannot-be-searched/251559/5 "2020-11-06T19:14:15Z")

</div>

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