Elasticsearch refactoring