I am using elasticsearch
. I see there is meta-field _id
for each document. I want to search document using this meta-field as I don't have any other field as unique field in document. But _id
is a string and can have dashes which are not possible to search unless we add mapping for field as type :keyword
. But it is possible as mentioned here. So now I am thinking to add another field newField
in document and make it same as _id
. One way to do it is: first create document and assign _id
to that field and save document again. But this will have 2 connections which is not that good. So I want to find some solution to set newField
while creating document itself. Is it even possible?
elasticsearch: copying meta-field _id to other field while creating document
1.2k views Asked by Rohanil At
2
There are 2 answers
1
On
you could also use a set processor when using an ingest pipeline to store the id in an additional field, see https://www.elastic.co/guide/en/elasticsearch/reference/5.5/accessing-data-in-pipelines.html and https://www.elastic.co/guide/en/elasticsearch/reference/5.5/set-processor.html
You can search for a document that contains dashes:
We just created a document with a dash in its id
We search for the document that have the following id:
testwith-
We found it. We can search on document that have - in it.