ElasticSearch RoutingMissingException

2020-07-03 07:14发布

I'm trying to populate objects having parent-child relation, but get an error:

[Elastica\Exception\ResponseException] RoutingMissingException[routing is required for [myindex]/[comment]/[12345]]

Excerpt from type conf:

article:
    _source:
        enabled: false
    mappings:
        ...

comment:
    _source:
        enabled: false
    _parent:
        type: article
        property: article_id
        identifier: id
    _routing:
        required: true
        path: article_id
    mappings:
        article:
            type: long
            index: not_analyzed
        ...

Cant understand what I am missing here....

I'm using Symfony2.3, FOSElasticaBundle 3.0, ElasticSearch 1.2.2

2条回答
叼着烟拽天下
2楼-- · 2020-07-03 07:41

Had typo in mappings.

comment:
    mappings:
        article_id: <-- was "article"
            type: long
            index: not_analyzed

Maybe this helps someone :)

查看更多
疯言疯语
3楼-- · 2020-07-03 07:49

When you have a parent child relationship, you need to specify the parent in the URL each time you try to access it a child, since routing now depends on the parent.

In your example, you'd want to try:

http://example.com/myindex/comment/12345?parent=[article_id]

查看更多
登录 后发表回答