Help me for mapping & query


(Mohammad Rashidi) #1

I have this mapping & query. everything is working, except when i want to filter those contents with mentioned "tagid"s. it returns zero results.

    {
  "mappings": {
    "video": {
      "_all": {
        "enabled": true
      },
      "properties": {
        "title": {
          "type": "string"
        },
        "en_title": {
          "type": "string"
        },
        "tags": {
          "type": "nested",
          "properties": {
            "tagname": {
              "type": "string"
            },
            "tagid": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "metadescription": {
          "type": "string"
        },
        "author": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "items": {
          "type": "nested",
          "properties": {
            "item_title": {
              "type": "string"
            },
            "item_duration": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        },
        "isfeatured": {
          "type": "string",
          "index": "not_analyzed"
        },
        "image": {
          "type": "string",
          "index": "not_analyzed"
        },
        "contenttype": {
          "type": "string",
          "index": "not_analyzed"
        },
        "category": {
          "type": "string",
          "index": "not_analyzed"
        },
        "categoryalias": {
          "type": "string",
          "index": "not_analyzed"
        },
        "url": {
          "type": "string",
          "index": "not_analyzed"
        },
        "authorid": {
          "type": "string",
          "index": "not_analyzed"
        },
        "price": {
          "type": "string",
          "index": "not_analyzed"
        },
        "duration": {
          "type": "string",
          "index": "not_analyzed"
        },
        "publishdate": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}

and this is the query:

    {
  "index": "content",
  "type": "video",
  "body": {
    "query": {
      "filtered": {
        "query": {
          "match_all": { }
        },
        "filter": {
          "bool": {
            "must": [
              {
                "nested": {
                  "path": "tags",
                  "query": {
                    "bool": {
                      "should": [
                        {
                          "term": {
                            "tagid": "193"
                          }
                        },
                        {
                          "term": {
                            "tagid": "194"
                          }
                        }
                      ]
                    }
                  }
                }
              },
              {
                "term": {
                  "categoryalias": "digilife"
                }
              },
              {
                "term": {
                  "price": 0
                }
              }
            ]
          }
        }
      }
    },
    "from": 0,
    "size": 9,
    "sort": [
      "_score"
    ]
  }
}

(system) #2