-
Notifications
You must be signed in to change notification settings - Fork 69
Commit 11f3667
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 11f3667Copy full SHA for 11f3667
File tree
Expand file treeCollapse file tree
1 file changed
+1
-0
lines changedFilter options
- lib/tasks
Expand file treeCollapse file tree
1 file changed
+1
-0
lines changedlib/tasks/elasticsearch.rake
Copy file name to clipboard+1Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + |
0 commit comments