elasticsearch - Querying nested objects not working -


this basic question cannot find what's wrong in query.

the mapping:

     {        "typename": {          "properties": {              "active": {                 "type": "boolean"              },              "id": {                 "type": "string",                 "index": "not_analyzed"              },              "values": {                 "type": "nested",                 "properties": {                 "by": {                     "type": "string",                     "analyzer": "english"                  },                  "idchatroom": {                     "type": "string",                     "analyzer": "english"                  },                  "message": {                     "type": "string",                     "analyzer": "english"                  }              }           }        } 

as can see there nested object called "values". if try run following query:

     plugg_co/chatmessage_50813808/_search      {         query: {            nested: {              path: "values",                 query: {                   filtered: {                      filter: {                         term: { "values.idchatroom": "id-123" }                      }                   }                }             }          }      } 

i don't result (the index not empty! checked!). idea?

thanks

there no problem in nested query. nested query fine.but since idchatroom analyzed that's why should not use term query on it.instead should use match query. change query to:

get plugg_co/chatmessage_50813808/_search { "query": {   "nested": {      "path": "values",      "query": {         "match": {            "values.idchatroom": "id-123"         }       }     }   }   } 

if want use term query can make not analysed or multifield. can refer https://www.elastic.co/guide/en/elasticsearch/reference/2.x/_multi_fields.html more information on multifield hope helps.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -