Feature request: Optional predefined indexMapping type
sbruggmann opened this issue · comments
In some cases it's required to have a string indexed as keyword
instead of just text
.
Could be solved like this in a single record:
data = {
"Athlete": "DEMTSCHENKO, Albert",
"Country": {
"mapping": "keyword",
"value": "RUS"
},
// ..
}
Or like this in a bulk ingestion file:
{ "index" : { "_index" : "olympics" } }
{"Athlete": "HAJOS, Alfred", "Country": {"mapping": "keyword", "value": "HUN"}, /* .. */}
I think this is the same as my request at https://zinc-nvh4832.slack.com/archives/C02QT4HCJ5P/p1642328076031900
@bbkane 👍
The automatic type definition is great for simple data, but there needs to be an optional solution to define the types manually.
I rethinked the proposed mapping configuration.
Of course it should follow the ES structure and we could say:
- The default single and bulk insertion is keeping the userfriendly automatic mapping and index creation.
- But if you need a specific mapping, you have create the index including a full mapping configuration upfront.
Endpoint:
PUT /api/index
Payload without specific mapping:
{
"name": "myshinynewindex",
"storage_type": "disk"
}
Payload with specific mapping:
{
"name": "myshinynewindex",
"storage_type": "disk",
"mappings": {
"properties": {
"author": {
"type": "text"
},
"identifier": {
"type:": "keyword"
}
}
}
}
This way it should be a rather small change in CreateIndex endpoint and a change in the indexer to not update the mapping if it was set manually upfront.
implemented at #71