在休眠搜索中启用动态分片会导致弹性搜索上的索引创建失败

时间:2016-06-21 15:12:45

标签: elasticsearch hibernate-search

我有一个场景,其中索引在简单的hibernate-search Elasticsearch集成设置中完美地运行,但是在启用分片时同样失败。在调试时,我看到启用了分片的hibernate搜索生成的json数据不正确。更多详情如下:

@Entity
public class AT {
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "ARRM_IDE", nullable = false)
    private A arr;

    private Date dateType;

    (and other fields)
}

@Entity
public class A {

    @Id
    @SequenceGenerator(name = "C_SEQUENCE", sequenceName = "S_ARRM_01")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "C_SEQUENCE")
    @Column(name = "IDE_ARR")
    private Long id;
}

SearchMapping mapping = new SearchMapping();
mapping.entity(AT.class).indexed()
        .property("dateType", ElementType.FIELD)
        .field()
        .store(Store.YES)
        .analyze(Analyze.NO)
        .property("arr", ElementType.FIELD)
        .indexEmbedded()
        .entity(A.class).indexed()
        .property("id", ElementType.FIELD).documentId().name("arrId")
        .field()
        .store(Store.YES)
        .analyze(Analyze.NO)
        ;

没有分片,架构映射和插入数据是这样的:

{"dynamic":"strict","properties":{"__HSearch_TenantId":{"type":"string","index":"not_analyzed"},"arr":{"properties":{"id":{"type":"long","store":true,"index":"not_analyzed","boost":1.0}}},"dateType":{"type":"date","store":true,"index":"not_analyzed","boost":1.0}}}"

"{"dateType":"2016-06-22T00:53:19Z","arr":{"id":15302}}"

我添加了以下内容以启用分片

<property name="hibernate.search.at.sharding_strategy" value="com....ATShardIdentifierProvider" />

这个映射与上面相同,插入数据如下:

"{"dateType":"2016-06-22T01:05:08Z","id":15402}"

然后索引显然失败了:

Status: 400
Error message: {"root_cause":[{"type":"strict_dynamic_mapping_exception","reason":"mapping set to strict, dynamic introduction of [id] within [AT] is not allowed"}],"type":"strict_dynamic_mapping_exception","reason":"mapping set to strict, dynamic introduction of [id] within [AT] is not allowed"}
Cluster name: null
Cluster status: 400

不确定这是不是错误?或者我的代码有点错误。

非常感谢您的帮助! 普里亚

0 个答案:

没有答案