refactoring Elasticsearch