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": {}
}
}
}
}
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": {}
}
}
}
}