Open semarco opened 9 years ago
Update: What we really would need is a timestamped index based on model attribute like 'time'.
elasticsearch!(
index_name: 'statistics',
index_timestamp: 'daily',
index_timestamp_field: 'time'
)
Maybe this is out of the concern of this gem, and we better use logstash?
You could try something like this in your model:
elasticsearch!
def es_index_name
"statistics-#{Time.strftime('%Y-%m-%d')}"
end
But I am unsure if it will work properly - untested. Please say if it works or not.
Thank you.
thanks a lot, but this would not solve the issue. 2 Problems:
class Statistic
elasticsearch!
attr_accessor :time
def es_index_name
"statistics-#{time.strftime('%Y-%m-%d')}"
end
end
We have to split a huge amount of statistic data into timestamped indexes, the selection of the index is by the Statistic#time not the current Time.
As far as I understand it should not be that difficult to use index-templates instead of creating an explicit index, have a look here http://rubydoc.info/gems/elasticsearch-api/Elasticsearch/API/Indices/Actions#put_template-instance_method
What do you think?
You could try to redefine this method to put models into different indexes: https://github.com/rs-pro/mongoid-elasticsearch/blob/master/lib/mongoid/elasticsearch/es.rb#L74-L76
If you need templates, probably it would be easier for you to do it with just elasticsearch gem, manually. I think it is outside of the scope of this gem.
As for searching, you will probably need multiple indexes and probably you will again be better with just es gem.
If you'l manage to get it working with this gem, and not force every index to use templates, and without hurting performance for other use cases, I'll welcome a pull request.
It would be great if you could support index-timestamping.
=>
statistics-2014-09-23
Is there a workaround we could have timestamped index names already? Thanks a lot for your help!