Get child doument by id

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
    _routing: {
        required: true
    }
    properties: {
        timestamp: {
            format: dateOptionalTime
            type: date
        }
        process-id: {
            index: not_analyzed
            type: string
        }
    }
    _parent: {
        type: MessageItem
    }
}
MessageItem: {
    properties: {
        timestamp: {
            format: dateOptionalTime
            type: date
        }
        status: {
            index: not_analyzed
            type: string
        }
    }
}

Thats because on top of the id of the child document, you need to provide
the parent id in the parent parameter or the routing parameter. The child
document ends up being assigned to the same shard as the parent, so getting
it requires knowledge of the parent id to properly route it.

On Wed, May 16, 2012 at 4:48 PM, Yuriy Bondaruk bondyk@gmail.com wrote:

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
_routing: {
required: true
}
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
process-id: {
index: not_analyzed
type: string
}
}
_parent: {
type: MessageItem
}
}
MessageItem: {
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
status: {
index: not_analyzed
type: string
}
}
}

Hi,

Thanks for the answer.

Now I have another questions:

  1. Is it possible to search child document in all parent docs by child id
    (I don't know the parent) in realtime (as GET operation)?

  2. Can I use GET request with specified parent-id + child-id or only POST
    search?

On Wed, May 16, 2012 at 10:49 PM, Shay Banon kimchy@gmail.com wrote:

Thats because on top of the id of the child document, you need to provide
the parent id in the parent parameter or the routing parameter. The child
document ends up being assigned to the same shard as the parent, so getting
it requires knowledge of the parent id to properly route it.

On Wed, May 16, 2012 at 4:48 PM, Yuriy Bondaruk bondyk@gmail.com wrote:

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
_routing: {
required: true
}
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
process-id: {
index: not_analyzed
type: string
}
}
_parent: {
type: MessageItem
}
}
MessageItem: {
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
status: {
index: not_analyzed
type: string
}
}
}

--
Best regards,
Yuriy Bondaruk

mailto: yuriy.bondaruk@gmail.com

On Wed, May 16, 2012 at 11:14 PM, Юрій Іванович Бондарук
bondyk@gmail.comwrote:

Hi,

Thanks for the answer.

Now I have another questions:

  1. Is it possible to search child document in all parent docs by child id
    (I don't know the parent) in realtime (as GET operation)?

If you don't know the parent id, then yes, you can do a search for it
instead.

  1. Can I use GET request with specified parent-id + child-id or only POST
    search?

Yes, you can do a GET request to get the child document by its id and the
parent. Just specify the parent id in the routing parameter. I will add a
parent parameter option as well...

On Wed, May 16, 2012 at 10:49 PM, Shay Banon kimchy@gmail.com wrote:

Thats because on top of the id of the child document, you need to provide
the parent id in the parent parameter or the routing parameter. The child
document ends up being assigned to the same shard as the parent, so getting
it requires knowledge of the parent id to properly route it.

On Wed, May 16, 2012 at 4:48 PM, Yuriy Bondaruk bondyk@gmail.com wrote:

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
_routing: {
required: true
}
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
process-id: {
index: not_analyzed
type: string
}
}
_parent: {
type: MessageItem
}
}
MessageItem: {
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
status: {
index: not_analyzed
type: string
}
}
}

--
Best regards,
Yuriy Bondaruk

mailto: yuriy.bondaruk@gmail.com

Here is the issue:
Get API: Allow to provide a parent value which automatically set the routing value · Issue #1961 · elastic/elasticsearch · GitHub (for now you can
simply set the routing value).

On Thu, May 17, 2012 at 1:25 AM, Shay Banon kimchy@gmail.com wrote:

On Wed, May 16, 2012 at 11:14 PM, Юрій Іванович Бондарук <bondyk@gmail.com

wrote:

Hi,

Thanks for the answer.

Now I have another questions:

  1. Is it possible to search child document in all parent docs by child id
    (I don't know the parent) in realtime (as GET operation)?

If you don't know the parent id, then yes, you can do a search for it
instead.

  1. Can I use GET request with specified parent-id + child-id or only POST
    search?

Yes, you can do a GET request to get the child document by its id and the
parent. Just specify the parent id in the routing parameter. I will add a
parent parameter option as well...

On Wed, May 16, 2012 at 10:49 PM, Shay Banon kimchy@gmail.com wrote:

Thats because on top of the id of the child document, you need to
provide the parent id in the parent parameter or the routing parameter. The
child document ends up being assigned to the same shard as the parent, so
getting it requires knowledge of the parent id to properly route it.

On Wed, May 16, 2012 at 4:48 PM, Yuriy Bondaruk bondyk@gmail.comwrote:

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
_routing: {
required: true
}
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
process-id: {
index: not_analyzed
type: string
}
}
_parent: {
type: MessageItem
}
}
MessageItem: {
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
status: {
index: not_analyzed
type: string
}
}
}

--
Best regards,
Yuriy Bondaruk

mailto: yuriy.bondaruk@gmail.com

Thanks for the enhancement. It works well!

On Thu, May 17, 2012 at 1:28 AM, Shay Banon kimchy@gmail.com wrote:

Here is the issue:
Get API: Allow to provide a parent value which automatically set the routing value · Issue #1961 · elastic/elasticsearch · GitHub (for now you
can simply set the routing value).

On Thu, May 17, 2012 at 1:25 AM, Shay Banon kimchy@gmail.com wrote:

On Wed, May 16, 2012 at 11:14 PM, Юрій Іванович Бондарук <
bondyk@gmail.com> wrote:

Hi,

Thanks for the answer.

Now I have another questions:

  1. Is it possible to search child document in all parent docs by child
    id (I don't know the parent) in realtime (as GET operation)?

If you don't know the parent id, then yes, you can do a search for it
instead.

  1. Can I use GET request with specified parent-id + child-id or only
    POST search?

Yes, you can do a GET request to get the child document by its id and the
parent. Just specify the parent id in the routing parameter. I will add a
parent parameter option as well...

On Wed, May 16, 2012 at 10:49 PM, Shay Banon kimchy@gmail.com wrote:

Thats because on top of the id of the child document, you need to
provide the parent id in the parent parameter or the routing parameter. The
child document ends up being assigned to the same shard as the parent, so
getting it requires knowledge of the parent id to properly route it.

On Wed, May 16, 2012 at 4:48 PM, Yuriy Bondaruk bondyk@gmail.comwrote:

Hi,

I have a problem with getting a child document by it's id. I send GET
request 'localhost:9200/test-index/ChildItem/41311aa0' and the
response says that item with the specified id doesn't exist. If use
_search query then the document is returning as expected.
But if I don't use parent/child configuration for ChildItem document
then GET operation works well.

Why ES doesn't return document by it's id when the parent/child
configuration is using? Or should I change GET request somehow?

Here is mapping of the child and parent:

ChildItem: {
_routing: {
required: true
}
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
process-id: {
index: not_analyzed
type: string
}
}
_parent: {
type: MessageItem
}
}
MessageItem: {
properties: {
timestamp: {
format: dateOptionalTime
type: date
}
status: {
index: not_analyzed
type: string
}
}
}

--
Best regards,
Yuriy Bondaruk

mailto: yuriy.bondaruk@gmail.com

--
Best regards,
Yuriy Bondaruk