유효하지 않은 쿼리가 있으면 Elasticsearch의 Java API (1.1.0)는 SearchPhaseExecutionException
을 발생시킵니다. 첫째유효하지 않은 Elasticsearch 쿼리를 잡는 방법?
Failed to execute phase [query_fetch], all shards failed; shardFailures {[bwUSN171Ru6rY1-su5-48A][f2f0i20hrf][0]: SearchParseException[[f2f0i20hrf][0]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"query":{"bool":{"must":{"term":{"count":""}}}}}]]]; nested: NumberFormatException[For input string: ""]; }
SearchParseException
에 대한 문자열 검색을 수행 이외의 다른 오류에서 유효하지 않은 쿼리를 구별 할 수 있습니까
, 또는 validating 쿼리 :이 예외는 아니 "원인"하지만,이 하나 같이 "메시지"가 없습니다 ?
ValidateQueryRequest validateQueryRequest = new ValidateQueryRequest(indexName);
validateQueryRequest.source(jsonContent);
validateQueryRequest.explain(true);
ActionFuture<ValidateQueryResponse> future = client.admin().indices().validateQuery(validateQueryRequest); // the client is org.elasticsearch.client.Client
ValidateQueryResponse response = future.get(); // typical java future as response
System.out.println(response.isValid()); // true or false
System.out.println(response.getQueryExplanation().size()); // size of explanations why the query is incorrect
QueryExplanation.getError이() 나는 번호 필드 범위와 텍스트를 사용하기 위해 노력하고있어 쿼리처럼 뭔가를 (제공 :
원인은'nested' 예외 (위의'NumberFormatException')입니다. 그러나 위의 예는 (숫자 자체가 누락 된 필드가 아니며) 문자열에서 명확하게 파싱 할 수없는 것처럼 유용하지는 않습니다. 나는 이것이별로 도움이되지 않는다는 것을 알고 있습니다. 그래서 그것이 답이 아닙니다. – pickypg
문제는,'getCause()'가'null'를 반환하는 한)'NumberFormatException' (또는'SearchParseException') 객체가 없다는 것입니다. 나는 getMessage() 문자열을 파싱하려고 시도 할 수 있다고 가정하지만 더 나은 해결책을 기대하고있다. – ejain