Spring数据elasticsearch,无法在路径下找到嵌套对象

时间:2015-04-21 15:20:01

标签: spring-data-elasticsearch

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

获得以下异常。

  

引起:org.elasticsearch.action.search.SearchPhaseExecutionException:无法执行阶段[dfs],所有分片都失败; shardFailures {[-EbBygdLRkKs49wqsf5ewQ] [support_team_idx] [0]:RemoteTransportException [[Artie] [local [6]] [indices:data / read / search [phase / dfs]]];嵌套:SearchParseException [[support_team_idx] [0]:来自[0],大小[10]:解析失败[无法解析源[{"来自":0,"大小": 10,"查询" {"嵌套" {"查询" {"布尔" {"必须" :[{"术语#34; {" supportteam.name":"测试"}},{"术语#34; {" supportteam.description":"测试"}}]}}"路径":" SupportTeam"}}}]]];嵌套:QueryParsingException [[support_team_idx] [嵌套]无法在路径[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();

0 个答案:

没有答案