Elasticsearch 异常 [类型=search_phase_execution_exception,原因=所有分片失败]
我正在 Spring Boot Rest API 中进行弹性搜索。我正在尝试添加基于距离的查询。我在运行时遇到以下异常:
Elasticsearch 异常 [type=search_phase_execution_exception, Reason=all shards failed];嵌套异常是 ElasticsearchStatusException[Elasticsearch 异常 [type=search_phase_execution_exception, Reason=all shards failed]]
以下是我的代码:
// Geo distance
GeoDistanceSortBuilder distanceSortBuilder = new GeoDistanceSortBuilder("location", latitude, longitude);
distanceSortBuilder.unit(DistanceUnit.MILES);
distanceSortBuilder.order(SortOrder.ASC);
DisMaxQueryBuilder searchByParameterQueryBuilder = QueryBuilders.disMaxQuery();
searchByParameterQueryBuilder.add(QueryBuilders.wildcardQuery(parameterType, "*" + searchParameter + "*"));
System.out.println(parameterType + ": " + searchByParameterQueryBuilder);
// System.out.println("");
// Distance query
QueryBuilder distanceQuery = new BoolQueryBuilder().must(QueryBuilders.geoDistanceQuery("location")
.point(latitude, longitude).distance(distance, DistanceUnit.MILES)).must(searchByParameterQueryBuilder);
// System.out.println("Distance query: " + distanceQuery);
Query searchQuery = new NativeSearchQueryBuilder().withFilter(distanceQuery).withSort(distanceSortBuilder)
.build();
System.out.println("Search query: " + searchQuery);
SearchHits<Elastic_Business_Service_Model> serviceHits = elasticsearchOperations.search(searchQuery,
Elastic_Business_Service_Model.class, IndexCoordinates.of(Business_Service_Index));
我不知道我做错了什么。
I am working on elastic search in spring boot rest API. I am trying to add distance based query. I am getting following exception while running:
Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]; nested exception is ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]
Following is my code:
// Geo distance
GeoDistanceSortBuilder distanceSortBuilder = new GeoDistanceSortBuilder("location", latitude, longitude);
distanceSortBuilder.unit(DistanceUnit.MILES);
distanceSortBuilder.order(SortOrder.ASC);
DisMaxQueryBuilder searchByParameterQueryBuilder = QueryBuilders.disMaxQuery();
searchByParameterQueryBuilder.add(QueryBuilders.wildcardQuery(parameterType, "*" + searchParameter + "*"));
System.out.println(parameterType + ": " + searchByParameterQueryBuilder);
// System.out.println("");
// Distance query
QueryBuilder distanceQuery = new BoolQueryBuilder().must(QueryBuilders.geoDistanceQuery("location")
.point(latitude, longitude).distance(distance, DistanceUnit.MILES)).must(searchByParameterQueryBuilder);
// System.out.println("Distance query: " + distanceQuery);
Query searchQuery = new NativeSearchQueryBuilder().withFilter(distanceQuery).withSort(distanceSortBuilder)
.build();
System.out.println("Search query: " + searchQuery);
SearchHits<Elastic_Business_Service_Model> serviceHits = elasticsearchOperations.search(searchQuery,
Elastic_Business_Service_Model.class, IndexCoordinates.of(Business_Service_Index));
I have no idea what I am doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论