Accessing nested document fields in nested queries

Hi all

I've have a doc with a nested document. in practice the nested field is an array.

first, is there a simple way to find all of a set of nested documents if I don't care about values in the root document?

if not, it seems I am unable to access the fields in the nested document when executing a nested query. but i can access fields in the root document. is this behavior expected?

below is the query i'm executing. it returns no fields in the result.

{
"query" : {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"parents.type" : "app"
}
}, {
"term" : {
"parents.id" : "C494277873EA9ADB1903CEA95F0C77C2"
}
} ]
}
},
"path" : "parents"
}
},
"fields" : [ "parents.type", "parents.id", "parents.name", "parents.version" ]
}

FWIW, the relevant portion of the mapping

"parents" : {
"properties" : {
"tags" : {
"analyzer" : "csv",
"type" : "string"
},
"id" : {
"index" : "not_analyzed",
"type" : "string"
},
"name" : {
"index" : "not_analyzed",
"type" : "string"
},
"type" : {
"index" : "not_analyzed",
"type" : "string"
}
},
"type" : "nested"
},

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

fwiw, looks like if the nested type isn't an array, I can access the nested values.

On Aug 15, 2011, at 1:16 PM, Chris K Wensel wrote:

Hi all

I've have a doc with a nested document. in practice the nested field is an array.

first, is there a simple way to find all of a set of nested documents if I don't care about values in the root document?

if not, it seems I am unable to access the fields in the nested document when executing a nested query. but i can access fields in the root document. is this behavior expected?

below is the query i'm executing. it returns no fields in the result.

{
"query" : {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"parents.type" : "app"
}
}, {
"term" : {
"parents.id" : "C494277873EA9ADB1903CEA95F0C77C2"
}
} ]
}
},
"path" : "parents"
}
},
"fields" : [ "parents.type", "parents.id", "parents.name", "parents.version" ]
}

FWIW, the relevant portion of the mapping

"parents" : {
"properties" : {
"tags" : {
"analyzer" : "csv",
"type" : "string"
},
"id" : {
"index" : "not_analyzed",
"type" : "string"
},
"name" : {
"index" : "not_analyzed",
"type" : "string"
},
"type" : {
"index" : "not_analyzed",
"type" : "string"
}
},
"type" : "nested"
},

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

--
Chris K Wensel
chris@concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

well, it turns out what I really want is a way to query and return only matching nested documents (, sometimes using criteria from the root document).

any pointers would be helpful. but I suspect this isn't an option (yet).

cheers,
chris

On Aug 15, 2011, at 1:39 PM, Chris K Wensel wrote:

fwiw, looks like if the nested type isn't an array, I can access the nested values.

On Aug 15, 2011, at 1:16 PM, Chris K Wensel wrote:

Hi all

I've have a doc with a nested document. in practice the nested field is an array.

first, is there a simple way to find all of a set of nested documents if I don't care about values in the root document?

if not, it seems I am unable to access the fields in the nested document when executing a nested query. but i can access fields in the root document. is this behavior expected?

below is the query i'm executing. it returns no fields in the result.

{
"query" : {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"parents.type" : "app"
}
}, {
"term" : {
"parents.id" : "C494277873EA9ADB1903CEA95F0C77C2"
}
} ]
}
},
"path" : "parents"
}
},
"fields" : [ "parents.type", "parents.id", "parents.name", "parents.version" ]
}

FWIW, the relevant portion of the mapping

"parents" : {
"properties" : {
"tags" : {
"analyzer" : "csv",
"type" : "string"
},
"id" : {
"index" : "not_analyzed",
"type" : "string"
},
"name" : {
"index" : "not_analyzed",
"type" : "string"
},
"type" : {
"index" : "not_analyzed",
"type" : "string"
}
},
"type" : "nested"
},

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

--
Chris K Wensel
chris@concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

Suspect validated :), its not an option (yet)...

On Tue, Aug 16, 2011 at 12:58 AM, Chris K Wensel chris@wensel.net wrote:

well, it turns out what I really want is a way to query and return only
matching nested documents (, sometimes using criteria from the root
document).

any pointers would be helpful. but I suspect this isn't an option (yet).

cheers,
chris

On Aug 15, 2011, at 1:39 PM, Chris K Wensel wrote:

fwiw, looks like if the nested type isn't an array, I can access the
nested values.

On Aug 15, 2011, at 1:16 PM, Chris K Wensel wrote:

Hi all

I've have a doc with a nested document. in practice the nested field is
an array.

first, is there a simple way to find all of a set of nested documents if
I don't care about values in the root document?

if not, it seems I am unable to access the fields in the nested document
when executing a nested query. but i can access fields in the root document.
is this behavior expected?

below is the query i'm executing. it returns no fields in the result.

{
"query" : {
"nested" : {
"query" : {
"bool" : {
"must" : [ {
"term" : {
"parents.type" : "app"
}
}, {
"term" : {
"parents.id" : "C494277873EA9ADB1903CEA95F0C77C2"
}
} ]
}
},
"path" : "parents"
}
},
"fields" : [ "parents.type", "parents.id", "parents.name",
"parents.version" ]
}

FWIW, the relevant portion of the mapping

"parents" : {
"properties" : {
"tags" : {
"analyzer" : "csv",
"type" : "string"
},
"id" : {
"index" : "not_analyzed",
"type" : "string"
},
"name" : {
"index" : "not_analyzed",
"type" : "string"
},
"type" : {
"index" : "not_analyzed",
"type" : "string"
}
},
"type" : "nested"
},

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading

--
Chris K Wensel
chris@concurrentinc.com
http://www.concurrentinc.com

-- Concurrent, Inc. offers mentoring, support for Cascading