java - Elastic search - need fields value based on their ID attribute -


i'm using elastic search trying value of field based on id attribute .

here rough picture of mapping

schoolid

schoolname

question1

            id =1              text = happy             comment : "value" 

question2

            id =2              text = sad             comment : "value" 

question3

             id =1               text = happy              comment : "value" 

and having document values

schoolid

schoolname

question1

            id =2              text = sad             comment : "value" 

question2

            id =1              text = happy              comment : "value" 

question3

             id =1               text = happy              comment : "value" 

and mapping code

{   "schools": {     "mappings": {       "admission": {         "properties": {           "createtime": {             "type": "date",             "format": "dateoptionaltime"           },           "q1": {             "properties": {               "as": {                 "properties": {                   "comment": {                     "type": "string"                   },                   "id": {                     "type": "long"                   },                   "text": {                     "type": "string"                   }                 }               },               "text": {                 "type": "string"               }             }           },           "q2": {             "properties": {               "as": {                 "properties": {                   "comment": {                     "type": "string"                   },                   "id": {                     "type": "long"                   },                   "text": {                     "type": "string"                   }                 }               },               "text": {                 "type": "string"               }             }           },           "q3": {             "properties": {               "as": {                 "properties": {                   "comment": {                     "type": "string"                   },                   "id": {                     "type": "long"                   },                   "text": {                     "type": "string"                   }                 }               },               "text": {                 "type": "string"               }             }           },           "schoolid": {             "type": "string"           },           "type": {             "type": "string"           },           "updatetime": {             "type": "date",             "format": "dateoptionaltime"           },           "v": {             "type": "string"           }         }       }     }   } } 

now need comment values questions id 1 i.e questions answered happy , id=1 .

not questions answered sad.

i using filters in ,

{    "fields": [       "question1.comment",       "question2.comment",       "question3.comment"    ],          "filter": {             "or": {                "filters": [                   {                      "term": {                         "question1.id": "1"                      }                   },                   {                      "term": {                         "question1.id": "1"                      }                   },                   {                      "term": {                         "question3.id": "1"                      }                   }                ]             }          } 

but giving me comments value including happy , sad question both .

but need comments happy questions not sad ones .

please !! in advance .


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -