Elastic search query issue


(venkatesh sapram) #1

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" : 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.


(system) #2