elasticsearch logic