Using parent property in update API doesnt seem to work

Hi -

If I try to add a document using the bulk update API (doc_as_upsert=true)
and set its parent property, I do not see the document as the child of the
specified parent when I make a has_parent query. Can you please help see
what could be wrong with the below. Thanks in advance.

Following is the mapping:

mappings: {
store: {
properties: {
name: {
type: string
}
owner: {
type: string
}
}
}
department: {
_routing: {
required: true
}
properties: {
name: {
type: string
}
numberOfProducts: {
type: long
}
}
_parent: {
type: store
}
}
}

Following is the bulk input file:

{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" :
"store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "update" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department2", "parent" : "store1" } }
{"doc" : { "name" : "dolls", "numberOfProducts" : 300 }, "doc_as_upsert" :
"true"}

Query -

{
"query": {
"has_parent": {
"type": "store",
"query": {
"match_all": {}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi Poorva,
you are right, I looked into it and this is most likely a bug. It seems
that we do read the parent, but we only use it for routing when updating a
document, while in case of doc_as_upsert we should also add the _parent to
the documents. Would you mind opening an issue herehttps://github.com/elasticsearch/elasticsearch/issues
?

On Sunday, August 4, 2013 2:08:33 AM UTC+2, Poorva Potnis wrote:

Hi -

If I try to add a document using the bulk update API (doc_as_upsert=true)
and set its parent property, I do not see the document as the child of the
specified parent when I make a has_parent query. Can you please help see
what could be wrong with the below. Thanks in advance.

Following is the mapping:

mappings: {
store: {
properties: {
name: {
type: string
}
owner: {
type: string
}
}
}
department: {
_routing: {
required: true
}
properties: {
name: {
type: string
}
numberOfProducts: {
type: long
}
}
_parent: {
type: store
}
}
}

Following is the bulk input file:

{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" :
"store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "update" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department2", "parent" : "store1" } }
{"doc" : { "name" : "dolls", "numberOfProducts" : 300 }, "doc_as_upsert"
: "true"}

Query -

{
"query": {
"has_parent": {
"type": "store",
"query": {
"match_all": {}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks! I opened the issue as you suggested.
Poorva

On Monday, August 5, 2013 7:34:59 AM UTC-7, Luca Cavanna wrote:

Hi Poorva,
you are right, I looked into it and this is most likely a bug. It seems
that we do read the parent, but we only use it for routing when updating a
document, while in case of doc_as_upsert we should also add the _parent to
the documents. Would you mind opening an issue herehttps://github.com/elasticsearch/elasticsearch/issues
?

On Sunday, August 4, 2013 2:08:33 AM UTC+2, Poorva Potnis wrote:

Hi -

If I try to add a document using the bulk update API (doc_as_upsert=true)
and set its parent property, I do not see the document as the child of the
specified parent when I make a has_parent query. Can you please help see
what could be wrong with the below. Thanks in advance.

Following is the mapping:

mappings: {
store: {
properties: {
name: {
type: string
}
owner: {
type: string
}
}
}
department: {
_routing: {
required: true
}
properties: {
name: {
type: string
}
numberOfProducts: {
type: long
}
}
_parent: {
type: store
}
}
}

Following is the bulk input file:

{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" :
"store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "update" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department2", "parent" : "store1" } }
{"doc" : { "name" : "dolls", "numberOfProducts" : 300 }, "doc_as_upsert"
: "true"}

Query -

{
"query": {
"has_parent": {
"type": "store",
"query": {
"match_all": {}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks a lot for opening the issue, it's fixed now. Also, the fix has
already been released with 0.90.3.

Cheers
Luca

On Monday, August 5, 2013 7:38:34 PM UTC+2, Poorva Potnis wrote:

Thanks! I opened the issue as you suggested.
Poorva

On Monday, August 5, 2013 7:34:59 AM UTC-7, Luca Cavanna wrote:

Hi Poorva,
you are right, I looked into it and this is most likely a bug. It seems
that we do read the parent, but we only use it for routing when updating a
document, while in case of doc_as_upsert we should also add the _parent to
the documents. Would you mind opening an issue herehttps://github.com/elasticsearch/elasticsearch/issues
?

On Sunday, August 4, 2013 2:08:33 AM UTC+2, Poorva Potnis wrote:

Hi -

If I try to add a document using the bulk update API
(doc_as_upsert=true) and set its parent property, I do not see the document
as the child of the specified parent when I make a has_parent query. Can
you please help see what could be wrong with the below. Thanks in advance.

Following is the mapping:

mappings: {
store: {
properties: {
name: {
type: string
}
owner: {
type: string
}
}
}
department: {
_routing: {
required: true
}
properties: {
name: {
type: string
}
numberOfProducts: {
type: long
}
}
_parent: {
type: store
}
}
}

Following is the bulk input file:

{ "index" : { "_index" : "parent_child", "_type" : "store", "_id" :
"store1" } }
{ "name" : "auchan", "owner" : "chris" }
{ "index" : { "_index" : "parent_child", "_type" : "department", "_id" :
"department1", "parent" : "store1" } }
{ "name" : "toys", "numberOfProducts" : 150 }
{ "update" : { "_index" : "parent_child", "_type" : "department", "_id"
: "department2", "parent" : "store1" } }
{"doc" : { "name" : "dolls", "numberOfProducts" : 300 },
"doc_as_upsert" : "true"}

Query -

{
"query": {
"has_parent": {
"type": "store",
"query": {
"match_all": {}
}
}
}
}

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.