Skip to content

Commit 11f3667

Browse files
committed
Add elasticsearch-rails rake tasks
This will allow importing data to ES indexes or recreating them. We need these tasks to solve http://community.coopdevs.org/t/busquedas-ofertas-demandas-sin-tener-en-cuenta-acentos/28/6. Basically, the required mapping were already present in the models long ago but the indexes were never recreated. While the `Post` model contains ```ruby settings( analysis: { analyzer: { normal: { tokenizer: "standard", # lowercase, unaccent filter: %w[lowercase asciifolding] } } } ) do mapping do indexes :title, analyzer: "normal" indexes :description, analyzer: "normal" indexes :tags indexes :organization_id, type: :integer end ``` The offers index does not have the same settings: ```shell { "offers": { "aliases": {}, "mappings": { "offer": { "properties": { "description": { "type": "string" }, "organization_id": { "type": "long" }, "tags": { "type": "string" }, "title": { "type": "string" } } } }, "settings": { "index": { "creation_date": "1484923146831", "uuid": "-3bRUbzeRxC5MRcVKwWsjQ", "number_of_replicas": "1", "number_of_shards": "5", "version": { "created": "2020099" } } }, "warmers": {} } } ``` After running: ```shell $ bundle exec rake environment elasticsearch:import:model CLASS='Offer' FORCE=y ``` The index reflects the new analyzer and mappings: ```shell { "offers": { "aliases": {}, "mappings": { "offer": { "properties": { "description": { "type": "string", "analyzer": "normal" }, "organization_id": { "type": "integer" }, "tags": { "type": "string" }, "title": { "type": "string", "analyzer": "normal" } } } }, "settings": { "index": { "creation_date": "1501241709326", "uuid": "ypU9Nws-SMu8KJ5MdUs8Aw", "analysis": { "analyzer": { "normal": { "filter": [ "lowercase", "asciifolding" ], "tokenizer": "standard" } } }, "number_of_replicas": "1", "number_of_shards": "5", "version": { "created": "2020099" } } }, "warmers": {} } } ```
1 parent 7cb6de5 commit 11f3667

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/tasks/elasticsearch.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require 'elasticsearch/rails/tasks/import'

0 commit comments

Comments
 (0)