Elasticsearch-rails: how to define dynamic templates?

Created on 26 Jun 2015  路  3Comments  路  Source: elastic/elasticsearch-rails

I cannot find any example where dynamic templates are defined with your gem?

ref: https://www.elastic.co/guide/en/elasticsearch/guide/current/custom-dynamic-mapping.html

Most helpful comment

Late to the party I know. But @adrienbourgeois it is possible:

```module MyIndex
settings index: {
max_result_window: 75_000,
} do
mapping dynamic_templates: [
{
strings: {
path_match: 'mypath.*',
match_mapping_type: 'string',
mapping: {
type: 'string',
analyzer: 'keyword',
}
}
}
] do
indexes :name, type: :string, analyzer: 'english'
end
end
end

All 3 comments

up

An acceptable solution for me would be to provide a simple json object or a hash for the mapping (instead of using the helpers from the gem) so I could define dynamic templates. Is there any way to "fallback" on a simple json object for the mapping configuration?

That's just an API call to Elasticsearch, so you should use the put_mapping method from the elasticsearch Rubygem.

Late to the party I know. But @adrienbourgeois it is possible:

```module MyIndex
settings index: {
max_result_window: 75_000,
} do
mapping dynamic_templates: [
{
strings: {
path_match: 'mypath.*',
match_mapping_type: 'string',
mapping: {
type: 'string',
analyzer: 'keyword',
}
}
}
] do
indexes :name, type: :string, analyzer: 'english'
end
end
end

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcoms picture mcoms  路  4Comments

davedash picture davedash  路  7Comments

fatbeard2 picture fatbeard2  路  8Comments

Meekohi picture Meekohi  路  4Comments

suras picture suras  路  6Comments