# Elastic search query issue

**URL:** <https://discuss.elastic.co/t/elastic-search-query-issue/41145>\
**Category:** Elasticsearch\
**Created:** [February 7, 2016, 5:38pm UTC](https://discuss.elastic.co/t/elastic-search-query-issue/41145 "2016-02-07T17:38:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ven2286](https://avatars.discourse-cdn.com/v4/letter/v/6f9a4e/32.png) [@ven2286](https://discuss.elastic.co/u/ven2286)\
**Post date:** [February 7, 2016, 5:38pm UTC](https://discuss.elastic.co/t/elastic-search-query-issue/41145/1 "2016-02-07T17:38:05Z")

</div>

I have a complex mapping for users some thing like this

{  
"user5": {  
"properties": {   
"lastName": {  
"type": "string"  
},  
"schedules": {  
"type": "nested",  
"properties": {  
"exercise": {  
"type": "nested",  
"properties": {  
"questionnaires": {  
"type": "nested",  
"properties": {  
"questions": {  
"type": "nested",  
"properties": {  
"score": {  
"type": "double"  
},  
"id": {  
"type": "long"  
},  
"type": {  
"type": "string"  
},  
"status": {  
"type": "string"  
}  
}  
},  
"id": {  
"type": "long"  
}  
}  
},  
"exerciseName": {  
"type": "string"  
},  
"id": {  
"type": "long"  
},  
"type": {  
"type": "string"  
}  
}  
},  
"id": {  
"type": "long"  
},

```
			"firstName": {
				"type": "string"
			},
											
		}
	}
},
"aliases": []

```

}

I want to find out the users who scored in a piticular question more than 1. My query is like this.

{

"query" : {  
"bool" : {  
"must" : [ {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"term" : {  
"[schedules.exercise.questionnaires.questions.id](http://schedules.exercise.questionnaires.questions.id)" : 1  
}  
},  
"path" : "schedules.exercise.questionnaires.questions"  
}  
},  
"path" : "schedules.exercise.questionnaires"  
}  
},  
"path" : "schedules.exercise"  
}  
},  
"path" : "schedules"  
}  
}, {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"nested" : {  
"query" : {  
"term" : {  
"schedules.exercise.questionnaires.questions.score" : 1.0  
}  
},  
"path" : "schedules.exercise.questionnaires.questions"  
}  
},  
"path" : "schedules.exercise.questionnaires"  
}  
},  
"path" : "schedules.exercise"  
}  
},  
"path" : "schedules"  
}  
} ]  
}  
}  
}

But i am getting wrong results. Can some body please correct my query.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:18pm UTC](https://discuss.elastic.co/t/elastic-search-query-issue/41145/2 "2017-07-05T23:18:21Z")

</div>

Closed on July 5, 2017, 11:18pm UTC


