Derive new fields from existing fields


(Ramchjob) #1

Dear Gurus,

I am looking dynamic mapping of the fields from the existing fields.

Ex: I have below document currently.

{
"id": "1b2b3c4d5e",
"active": true,
"lastName": "Mike",
"firstName": "Walter",
"gender": "male",
"dob": "1967-11-27T19:26:27.844Z"
}

Would like to add new dynamic mapping

{
"id": "1b2b3c4d5e",
"active": true,
"lastName": "Mike",
"firstName": "Walter",
"gender": "male",
"dob": "1967-11-27T19:26:27.844Z",
"lastName_firstName_dob":"WalterMike1967-11-27T19:26:27.844Z"
}

I followed the below and have created the index as well.

https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-all.html

But after i created document, i don't find the new dynamic field after i pull the documents using search.

Please guide me on the same


(Melvyn Peignon) #2

I think there is some confusion here, and I don't really understand what you are trying to do.

A mapping is the "schema" that will have your documents. For instance:

"mappings": {
   "doc": {
    "properties": {
       "id": {"type":"keyword"},
       "active": {"type":"boolean"},
       "lastName": {"type":"keyword"},
       "Firstname": {"type":"keyword"},
       "gender": {"type":"keyword"},
       "dob": {"type":"keyword"}
    }
  }
}

It will allow Elasticsearch to build the data structure behind the scene in order to make your data searchable.

The "Dynamic mapping" is a behaviour that has Elasticsearch. When you are indexing a document without specifying any mappings, Elasticsearch will try to guess the type of every field in your document, and generate a mapping for the corresponding index/doc_type.

If you are adding a new field that has never been indexed in Elasticsearch before, by default Elasticsearch will try to guess the type of the new field and add it to the mapping (dynamic mapping).

Now there is this _all that was by default creating a big string out of your document and index it. This is deprecated in 6.X, you should have a look at copy_to: https://www.elastic.co/guide/en/elasticsearch/reference/6.x/copy-to.html I hope this will answer your questions.


(Ramchjob) #3

Thanks for the reply @Melvyn, I got it.


(system) #4

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