У меня естьasticSearch 7.4. У меня есть модель Address и вложенные модели 'parts' типа Entry:
@Document(indexName = "address", createIndex = true)
public class Address {
@Id
@Field(type = FieldType.Text, store = true)
public String id;
@Field(type = FieldType.Text)
private String fullAddress;
private String regionCode;
private boolean customQuery = true;
private boolean root;
@Field(type = FieldType.Nested, store = true)
private List<Entry> parts;
@Field(type = FieldType.Nested, store = true)
private House house;
}
public class Entry {
private String aoid;
private String aoGuid;
private String code;
private String offName;
private String parentGuid;
private String shortName;
@Field(type = FieldType.Integer)
private Integer aoLevel;
private String postalCode;
}
Я хочу написать запрос в поле AoGuid из списка Entry:
@Override
public List<Address> findForHouse(String aoguid) {
SearchSourceBuilder builder = new SearchSourceBuilder();
NestedQueryBuilder findByparts = nestedQuery(
"parts",
termQuery("parts.aoGuid", aoguid),
ScoreMode.None);
TermQueryBuilder findByRoot = termQuery("root", true);
QueryBuilder findByIdAndLocation = QueryBuilders.boolQuery()
.filter(findByRoot)
.filter(findByparts);
builder.query(findByIdAndLocation);
String[] strings = new String[]{"address"};
SearchRequest request = new SearchRequest(strings, builder);
try {
restHighLevelClient.search(request, RequestOptions.DEFAULT);
} catch (IOException e) {
e.printStackTrace();
}
}
Когда я при вызове метода поиска я получаю сообщение об ошибке:
org.elasticsearch.ElasticsearchStatusException: исключение Elasticsearch [type = search_phase_execution_exception, причина = сбой всех шардов] в org.elasticsearch.rest .BytesRestResponse.errorFromXContent (BytesRestResponse. java: 177) ~ [asticsearch-7.4.0.jar: 7.4.0] в org.elasticsearch.client.RestHighLevelClient.parseEntity (RestHighLevelClise. rest-high-level-client-7.4.0.jar: 7.4.0] в org.elasticsearch.client.RestHighLevelClient.parseResponseException (RestHighLevelClient. java: 1704) ~ [asticsearch-rest-high-level-client-7.4 .0.jar: 7.4.0] at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest (RestHighLevelClient. java: 1467) ~ [asticsearch-rest-high-level-client-7.4.0.jar: 7.4.0] на org.elasticsearch.c lient.RestHighLevelClient.performRequest (RestHighLevelClient. java: 1424) ~ [asticsearch-rest-high-level-client-7.4.0.jar: 7.4.0] в org.elasticsearch.client.RestHighLevelClient.performRequestAliteHentElientClient. 1036 *: 1394) ~ [asticsearch-rest-high-level-client-7.4.0.jar: 7.4.0] в org.elasticsearch.client.RestHighLevelClient.search (RestHighLevelClient. java: 930) ~ [asticsearch- rest-high-level-client-7.4.0.jar: 7.4.0] at ru.evolenta.server.service.elasti c .impl.ElasticQueryAddressServiceImpl.findForHouse (ElasticQueryAddressServiceImpl. java: 117) ~ [классы / : na] at ru.evolenta.server.service.asyn c .impl.AsyncHouseElasticServiceImpl.lambda $ saveFias $ 1 (AsyncHouseElasticServiceImpl. java: 45) ~ [classes /: na] в java .util.stream. ForEachOps $ ForEachOp $ OfRef.accept (ForEachOps. java: 184) ~ [na: 1.8.0_201] в java .util.Spliterators $ ArraySpliterator.forEachRemaining (Spliterators. java: 948) ~ [na: 1.8 .0_201] at java .util.stream.AbstractPipeline.copyInto (AbstractPipeline. java: 481) ~ [na: 1.8.0_201] в java .util.stream.ForEachOps $ ForEachTask.compute (ForEachOps. java: 291) ~ [na: 1.8.0_201] в java. util.concurrent.CountingCompleter.exe c (CountedCompleter. java: 731) ~ [na: 1.8.0_201] в java .util.concurrent.ForkJoinTask.doExe c (ForkJoinTask. java: 289 ) ~ [na: 1.8.0_201] в java .util.concurrent.ForkJoinTask.doInvoke (ForkJoinTask. java: 401) ~ [na: 1.8.0_201] в java .util.concurrent.ForkJoinTask.invoke (ForkJoinTask. java: 734) ~ [na: 1.8.0_201] в java .util.stream.ForEachOps $ ForEachOp.evaluateParallel (ForEachOps. java: 160) ~ [na: 1.8.0_201] в java .util.stream.ForEachOps $ ForEachOp $ OfRef.evaluateParallel (ForEachOps. java: 174) ~ [na: 1.8.0_201] в java .util.stream.AbstractPipeline.evaluate (AbstractPipeline. java: 233) ~ [na: 1.8.0_201] в java .util.stream.ReferencePipeline.forEach (ReferencePipeline. java: 418) ~ [na: 1.8.0_201] в java .util.stream.ReferencePipeline $ Head.forEach (ReferencePipeline. java: 583) ~ [na: 1.8.0_201] на ru.evolenta.server.se rvice.asyn c .impl.AsyncHouseElasticServiceImpl.saveFias (AsyncHouseElasticServiceImpl. java: 42) ~ [classes /: na] at sun.reflect.NativeMethodAccessorImpl.invoke0 (собственный метод )_2011: 1.8.0 , 1074 * .lang.reflect.Method.invoke (Метод. java: 498) ~ [na: 1.8.0_201] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (AopUtils. java: 338) ~ [ spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint (ReflectiveMethodInvocation. java: 197) ~ [spring-aop-5.0.4.RELE .jar: 5.0. 4.RELEASE] в org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (ReflectiveMethodInvocation. java: 163) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в org.springframe. aop.interceptor.AsyncExecutionInterceptor.lambda $ invoke $ 0 (AsyncExecutionInterceptor. java: 115) ~ [spring-aop-5.0.4.RELEASE.jar: 5.0.4.RELEASE] в java .util.concurrent.FutureTask. запустите $$$ capture (FutureTask. java: 266) ~ [na: 1.8.0_201] в java .util.concurrent.FutureTask.run (FutureTask. java) ~ [na: 1.8.0_201] в java .util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor. java: 1149) ~ [na: 1.8.0_201] в java .util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor. java 6: ) ~ [na: 1.8.0_201] at java .lang.Thread.run (Thread. java: 748) ~ [na: 1.8.0_201] Подавлено: org.elasticsearch.client.ResponseException: метод [POST], хост [http://localhost: 9200] , URI [/ address / _search? Typed_keys = true & ignore_unavailable = false & expand_wildcards = open & allow_no_indices = true & ignore_throttled = t rue & search_type = query_then_fetch & batched_reduce_size = 512 & ccs_minimize_roundtrips = true], строка состояния [HTTP / 1.1 400 Bad Request] {"error": {"root_cause": [{"type": "query_shard_exception", "reason": "не удалось создать запрос: { \ n \ "bool \": {\ n \ "filter \": [\ n {\ n
\ "term \": {\ n \ "root \": {\ n \ "value \": true, \ n \ "boost \": 1.0 \ n} \ n} \ n}, \ n {\ n
\ "nested \": {\ n \ "query \": {\ n \ "term \ ": {\ n
\" parts.aoGuid \ ": {\ n \" value \ ": \" 2d598ce8-feaf-4fb0-9320-bcad370a5d52 \ ", \ n \" boost \ ": 1.0 \ n} \ n} \ n}, \ n \ "path \": \ "parts \", \ n \ "ignore_unmapped \": false, \ n
\ "score_mode \": \ "none \", \ n \ "boost \": 1.0 \ n} \ n
} \ n], \ n \ "Adjust_pure_negative \": true, \ n \ "boost \": 1.0 \ n} \ n} "," index_uuid ":" jqAtS-hiQOS08lKfa1nWqw "," index ":" address "}]," type ":" search_phase_execution_exception "," reason ":" сбой всех сегментов "," phase ":" query "," grouped ": true , "failed_shards": [{ "осколок": 0, "индекс": "адрес", "узел": "G_1M-1l6SOyy7YHWBk2SSQ", "причина": { "типа": "query_shard_exception", "причина": "не удалось создать запрос: {\ n \ "bool \": {\ n \ "filter \": [\ n {\ n
\ "term \": {\ n \ "root \": {\ n \ "value \": true, \ n \ "boost \": 1.0 \ n} \ n} \ n}, \ n {\ n
\ "nested \": {\ n \ "query \": { \ n \ "term \": {\ n
\ "parts.aoGuid \": {\ n \ "value \": \ "2d598ce8-feaf-4fb0-9320-bcad370a5d52 \", \ n \ "boost \ ": 1.0 \ n} \ n} \ n}, \ n \" path \ ": \" parts \ ", \ n \" ignore_unmapped \ ": false, \ n
\" score_mode \ ": \ "none \", \ n \ "boost \": 1.0 \ n} \ n
} \ n], \ n \ "Adjust_pure_negative \": true, \ n \ "boost \": 1.0 \ n} \ n} "," index_uuid ":" jqAtS-hiQOS08lKfa1nWqw "," index ":" address "," reason_by ": {" type ":" invalid_state_exception "," reason ":" [вложенный] вложенный объект в пути [parts] не имеет вложенного типа "}}}]}," status ": 400} at org.elasticsearch.client.RestClient.convertResponse (RestClient. java: 253) ~ [asticsearch-rest-client-7.4. 0.jar: 7.4.0] в org.elasticsearch.client.RestClient.performRequest (RestClient. java: 231) ~ [asticsearch-rest-client-7.4.0.jar: 7.4.0] в org.elasticsearch. client.RestClient.performReq uest (RestClient. java: 205) ~ [asticsearch-rest-client-7.4.0.jar: 7.4.0] в org.elasticsearch.client.RestHighLevelClient.internalPerformRequest (RestHighLevelClient. java: 1454) ~asticsearch -rest-high-level-client-7.4.0.jar: 7.4.0] ... пропущено 32 общих кадра
Как это исправить?