Parent/child or nested mapping?


(Greg) #1

Hi all

The JSON documents that I am indexing are of the following format:

"user" : {
"name" : "Me",
"email" : "me@example.com",
"articles" : [
{
"title" : "Title 1",
"body" : "Body 1",
"tags" : ["tag1", "tag2"]
},
{
"title" : "Title 2",
"body" : "Body 2"
"tags" : ["tag2", "tag3"]
}
]
}

Each user has one or more articles. I predominantly need to search for
articles across all users, e.g. all articles with a tag of 'tag2'.

My questions are as follows:

  1. What is the difference between a parent/child and nested mapping?

  2. Is it generally acceptable to organise this information into a
    nested JSON document, or is there a better way to define the
    relationship between users and articles?

Many thanks

Greg


(Shay Banon) #2

What search results to you expect to get? Is it articles that match your query or users?

On Friday, February 3, 2012 at 3:28 PM, Greg wrote:

Hi all

The JSON documents that I am indexing are of the following format:

"user" : {
"name" : "Me",
"email" : "me@example.com (mailto:me@example.com)",
"articles" : [
{
"title" : "Title 1",
"body" : "Body 1",
"tags" : ["tag1", "tag2"]
},
{
"title" : "Title 2",
"body" : "Body 2"
"tags" : ["tag2", "tag3"]
}
]
}

Each user has one or more articles. I predominantly need to search for
articles across all users, e.g. all articles with a tag of 'tag2'.

My questions are as follows:

  1. What is the difference between a parent/child and nested mapping?

  2. Is it generally acceptable to organise this information into a
    nested JSON document, or is there a better way to define the
    relationship between users and articles?

Many thanks

Greg


(system) #3