We allow the client to define custom analyzers at the time they create an index. We would prefer to specify this in json to provide maximum flexibility and understandability via the underlying ElasticSearch documentation.
I would like to create an index using an arbitrary description of analyzers, mappers, etc., defined in a json string. Using sense, my command is
PUT /my_index
{
"settings":
{
"analysis":
{
"char_filter" :
{
"my_mapping" :
{
"type" : "mapping",
"mappings" : [".=>,", "'=>,"]
}
},
"analyzer":
{
"my_analyzer":
{
"type": "custom",
"tokenizer": "standard",
"filter": ["lowercase" ],
"char_filter" : ["my_mapping"]
}
}
}
}
}
}
Ideally, my code would look something like
string json = RetrieveJson();
ElasticSearchClient client = InitializeClient();
client.CreateIndexUsingJson( json ); // this is the syntax I can't figure out
The post here attempts to do this by instantiating an IndexSettings then calling Add( "analysis", json ), but Add is not a function on the ElasticSearch library version I'm using.
The options I can imagine include:
- Somehow using the ElasticClient.Raw.IndicesCreatePost or something analogous
- Deserializing the json string into an IndexSettings object via IndexSettingsConverter.ReadJson(), and then applying that through ElasticClient.CreateIndex(ICreateIndexRequest)
Both of these mechanisms have very scant documentation.
I'm absolutely trying to avoid the lambda function versions of CreateIndex, since it would be miserable to translate the user's json into lamdba expressions, only to immediately translate them back into json deep in NEST.
Other options or concrete examples of #1 or #2 above are very much appreciated, as is a recommended approach to solving this problem.