/** * Validates that all fields used in the query actually exist in the index definition. * * TODO: shouldn't we also validate that the requested sort order corresponds with the indexed order etc? * * @param query query to validate */ private void validateQuery(Query query) { for (Query.EqualsCondition eqCond : query.getEqConditions()) { if (definition.getField(eqCond.getName()) == null) { throw new MalformedQueryException( String.format("The query refers to a field which does not exist in this index: %1$s", eqCond.getName())); } } if (query.getRangeCondition() != null && definition.getField(query.getRangeCondition().getName()) == null) { throw new MalformedQueryException( String.format("The query refers to a field which does not exist in this index: %1$s", query.getRangeCondition().getName())); } }