1

我正在尝试使用 Spring 数据弹性搜索。我还阅读了这个Spring Data Elastic Search with Nested Fields and mapping

得到以下异常。

原因:org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], all shards failed;shardFailures {[-EbBygdLRkKs49wqsf5ewQ][support_team_idx][0]: RemoteTransportException[[Artie][local[6]][indices:data/read/search[phase/dfs]]]; 嵌套:SearchParseException [[support_team_idx][0]:来自[0],大小[10]:解析失败[无法解析源[{“from”:0,“size”:10,“query”:{“nested” :{"query":{"bool":{"must":[{"term":{"supportteam.name":"test"}},{"term":{"supportteam.description":"test" }}]}},"path":"SupportTeam"}}}]]]; 嵌套:QueryParsingException[[support_team_idx] [nested] 未能在路径 [SupportTeam]] 下找到嵌套对象;}

实体:

  @Document(indexName = "support_team_idx", type = "support_team_type", indexStoreType= "memory", shards = 1, replicas = 0,  refreshInterval = "-1")
public class SupportTeam extends BaseEntity implements Serializable {
  private static final long serialVersionUID = 1L;

  @Field(type=FieldType.String, index=FieldIndex.analyzed)
  private String name;
  @Field(type=FieldType.String, index=FieldIndex.analyzed)
  private String description;

  @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
  @JoinColumn(name = "org_unit_id", unique = false)
  @Field(type=FieldType.Nested)
  private OrgUnit orgUnit;

  @OneToMany(mappedBy = "supportTeam", fetch = FetchType.EAGER)
  @Field(type = FieldType.Nested)
  private Set<SupportTeamMember> supportTeamMembers;

  public SupportTeam() {}
 }

log.info("Initializing Indexs");
    RootConfig.elasticsearchTemplate().deleteIndex(SupportTeam.class);
    RootConfig.elasticsearchTemplate().createIndex(SupportTeam.class);
    RootConfig.elasticsearchTemplate().putMapping(SupportTeam.class);
    RootConfig.elasticsearchTemplate().refresh(SupportTeam.class, true);

……

 SearchQuery searchQuery = new NativeSearchQueryBuilder()
 .withQuery(nestedQuery("SupportTeam",           
  boolQuery().must(termQuery("supportteam.name", .
  searchText)).must(termQuery("supportteam.description", searchText))))
 .withIndices("support_team_idx").build();
4

0 回答 0