# Find exact data when the type is text

**URL:** <https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559>\
**Category:** Elasticsearch\
**Created:** [June 19, 2018, 7:05pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559 "2018-06-19T19:05:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [June 19, 2018, 7:05pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/1 "2018-06-19T19:05:10Z")

</div>

I have a mapping using the `type: text` to store emails, can I search for documents that have a value exactly the same as what was written in the field of type text?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 19, 2018, 9:08pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/2 "2018-06-19T21:08:24Z")

</div>

Unless you used keyword analyzer, you lost some information during the indexing, so you cannot do exact match completely in elasticsearch. However, you can get pretty close by using [phrase query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html) and then you can retrieve the documents to see if source matches your query.

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [June 20, 2018, 11:42am UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/3 "2018-06-20T11:42:12Z")

</div>

Hi @Igor_Motov.

Today with ES 6.2 is possible create a new property in my actual mapping, but is possible copy the content from one property to another? Otherwise, I'll have to resynchronize a lot of information.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 20, 2018, 4:24pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/4 "2018-06-20T16:24:58Z")

</div>

Yes. You can add a keyword field to the mapping and reindex.

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [June 20, 2018, 4:39pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/5 "2018-06-20T16:39:13Z")

</div>

But is it possible without reindexing all 3M of existing documents? Just copy and paste the value from one property to another?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 20, 2018, 7:59pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/6 "2018-06-20T19:59:19Z")

</div>

You cannot modify a document without reindexing it. All document updates are done atomically to the entire document. Reindexing 3 million documents should not take too long

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [June 20, 2018, 8:17pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/7 "2018-06-20T20:17:01Z")

</div>

Sorry, I asked the wrong question.

The correct would be if it is possible to create the new property of type keyword and copy the values ​​directly from the property of type text (through Elasticsearch), without having to send all the records via cURL again to be modified.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 21, 2018, 2:15pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/8 "2018-06-21T14:15:39Z")

</div>

Yes, you can use [reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/docs-reindex.html) and make a copy with a script or by using ingest node. However, you don't actually have to make a copy of the field - you can simply modify the mapping to [index the same field twice](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/multi-fields.html) by modifying mapping and running [update by query api](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/docs-update-by-query.html).

---

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [June 21, 2018, 2:27pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/9 "2018-06-21T14:27:47Z")

</div>

Thanks Igor.  
These commands are awesome.

---

<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 19, 2018, 2:27pm UTC](https://discuss.elastic.co/t/find-exact-data-when-the-type-is-text/136559/10 "2018-07-19T14:27:50Z")

</div>

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