Find exact data when the type is text

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?

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 and then you can retrieve the documents to see if source matches your query.

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.

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

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

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

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.

Yes, you can use reindex API 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 by modifying mapping and running update by query api.

1 Like

Thanks Igor.
These commands are awesome.

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