Try using full element path in term filter -
"sectionResults.itemResults.InspectionItem"
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"nested": {
"path": "sectionResults.itemResults",
"filter": {
"bool": {
"must": [
{
"term": {
"sectionResults.itemResults.InspectionItem": "Project
Name"
}
}
]
}
}
}
}
}
}
On Thursday, October 16, 2014 12:59:13 PM UTC+2, shekhar chauhan wrote:
>
> Hi All,
> I am facing a problem in searcing a nested object.My document structure
> is -
>
> {
> "sectionResults": [
> {
> "SectionName": "More Details",
> "itemResults": [
>
> {
> "InspectionItem": "Project Name",
> "ItemInfo": ""
>
> }
> ]
> }
>
> ]
> }
>
> and I have used this mapping query to make itemResults object(in document)
> of nested type -
> PUT realtek_release_v6_nestedsearch/_mapping
> {
> "realtek_release_v6_nestedsearch":{
> "properties": {
> "sectionResults":{
> "type": "object",
> "properties": {
> "itemResults":{
> "type": "nested"
> }
> }
> }
> }
> }
> }
>
> then i have checked the mapping .In mapping itemResults of nested type.
> Everything if fine here.
> But problem comes in searching query for nested object.my searching query
> is -
>
> "query": {
> "filtered": {
> "query": {
> "match_all": {}
> },
> "filter": {
> "nested": {
> "path": "sectionResults.itemResults",
> "filter": {
> "bool": {
> "must": [
> {
> "term": {
> "itemResults.InspectionItem": "Project Name"
> }
> }
> ]
> }
> }
> }
> }
> }
> }
>
> this query returns 0 matching results.but result exists in database.I do
> not know whether i am doing mistake in mapping or search query.Please help.
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/d538201f-39f4-48a6-ad9b-b0f83b0b68ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.