Grails Elasticsearch autoIndex删除导致RoutingMissingException

时间:2018-08-24 11:23:37

标签: elasticsearch grails elasticsearch-plugin

我在elasticsearch autoIndexing上存在问题,并从数据库中删除了一个域,这导致了RoutingMissingException。 如果从数据库中删除了可搜索域实例,elasticsearch会自动从索引中删除相应的文档。 问题在于,域实例是子实例,并且需要路由,因此引发了RoutingMissingException。

我正在使用Grails 2.3.11和带Elasticsearch 2.3.3的elasticsearch-plugin 1.2.0。 我的elasticsearch索引有两种类型“ parent”和“ child”(在此示例中重命名),它们显然具有父子关系。

孩子的映射:

"child": {
    "_all": {
        "analyzer": "german"
    },
    "_parent": {
        "type": "parent"
    },
    "_routing": {
        "required": true
    },
    ...

在子域类中:

...

static belongsTo = [parent: Parent] 

static searchable = {
    ...
    parent parent: true, reference: true
    ...
}

现在,如果我在方法中删除子域的实例:

...
def deletableChild = Child.load(params.id)
flow.parentInstance.removeFromChilds(deletableChild)
deletableChild.delete()
...

我收到以下错误:     错误[12:44:17] [IndexRequestQueue]:批量项目失败:[index] RoutingMissingException [[index] / [child] / [3790]]需要路由]

然后在elasticsearch日志中:

[2018-08-24 12:44:17,314][WARN ][action.delete            ] [Outrage] unexpected error during the primary phase for action [indices:data/write/delete], request [delete {[index][child][3790]}]
[index] RoutingMissingException[routing is required for [index]/[child]/[3790]]
    at org.elasticsearch.action.delete.TransportDeleteAction.resolveAndValidateRouting(TransportDeleteAction.java:118)
    at org.elasticsearch.action.delete.TransportDeleteAction.resolveRequest(TransportDeleteAction.java:100)
    at org.elasticsearch.action.delete.TransportDeleteAction.resolveRequest(TransportDeleteAction.java:54)

如果我将disableAutoIndex设置为true并使用?routing = id&parent = id从索引中手动删除该子项,则它会起作用。我是否缺少一些必要的设置才能使autoIndex正常运行?

0 个答案:

没有答案