Find exact data when the type is text

(Flavio Tom) #1

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?

(Igor Motov) #2

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.

(Flavio Tom) #3

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.

(Igor Motov) #4

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

(Flavio Tom) #5

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

(Igor Motov) #6

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

(Flavio Tom) #7

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.

(Igor Motov) #8

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.

(Flavio Tom) #9

Thanks Igor.
These commands are awesome.

(system) #10

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