How to define mapping in runtime


(sreeram) #1

Hi,

I'm using Elasticsearch 2.3.4 & Elasticsearch.Net (Low-level client) SDK for indexing JSON documents which are dynamic in nature.

I want to create mapping for my JSON structure before indexing documents in order to avoid field type getting detected (numeric_detection & date_detection = True) wrongly while inserting the first document.

How to PUT below mapping (JSON) through Elasticsearch.Net Or NEST SDK API?!
PUT my_index
{
"mappings": {
"user": {
"_all": { "enabled": false },
"properties": {
"title": { "type": "string" },
"name": { "type": "string" },
"age": { "type": "integer" }
}
},
"blogpost": {
"properties": {
"title": { "type": "string" },
"body": { "type": "string" },
"user_id": {
"type": "string",
"index": "not_analyzed"
},
"created": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
}
}
}
}
}

Regards,
Sreeram


Elasticsearch Define Dynamic Mapping
(sreeram) #2

Someone help me out. Is there anyway to do this ?


(Magnus B├Ąck) #3

Does https://www.elastic.co/guide/en/elasticsearch/client/net-api/1.x/create-indices.html help? Which version of the libraries are you using?

Someone help me out. Is there anyway to do this ?

Be patient.


(sreeram) #4

Thanks for your response. I'll Check and update.


(system) #5