Q: How to get by ids and filter nested data to leave only objects filtered by category? How to get by ids and filter notes to leave only given category?
Data:
POST c1_2/Blog/1
{
  "post": {
    "notes": {
      "main": [
        {
          "message": "blablabla",
          "category": "test"
        },
        {
          "message": "blablabla",
          "category": "other"
        }
      ],
      "cart": [
        {
          "message": "blablabla",
          "category": "test"
        },
        {
          "message": "blablabla",
          "category": "other"
        }
      ]
    }
  }
}

POST c1_2/Blog/2
{
  "post": {
    "notes": {
      "main": [
        {
          "message": "blablabla",
          "category": "second"
        },
        {
          "message": "blablabla",
          "category": "third"
        }
      ],
      "cart": [
        {
          "message": "blablabla",
          "category": "test"
        },
        {
          "message": "blablabla",
          "category": "other"
        }
      ]
    }
  }
}

Search:
POST c1_2/Blog/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "ids": {
            "values": [
              1,
              2,
              3
            ]
          }
        },
        {
          "terms": {
            "post.notes.main.category": [
              "test"
            ]
          }
        }
      ]
    }
  }
}

Current results, objects in notes main/cart aren't filtered by category:
{
   "took": 9,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1.0122644,
      "hits": [
         {
            "_index": "c1_2",
            "_type": "Blog",
            "_id": "1",
            "_score": 1.0122644,
            "_source": {
               "post": {
                  "notes": {
                     "main": [
                        {
                           "message": "blablabla",
                           "category": "test"
                        },
                        {
                           "message": "blablabla",
                           "category": "other"
                        }
                     ],
                     "cart": [
                        {
                           "message": "blablabla",
                           "category": "test"
                        },
                        {
                           "message": "blablabla",
                           "category": "other"
                        }
                     ]
                  }
               }
            }
         }
      ]
   }
}

Desired effect:
"notes": {
   "main": [
      {
         "message": "blablabla",
         "category": "test"
      }
   ],
   "cart": [
      {
         "message": "blablabla",
         "category": "test"
      }
   ]
}

In my real app query is embedded in "filtered" and "filter", if I will put query above instead filter "ids" like in example below, then will it return the same data?
POST c1_2/Blog/_search 
{
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "ids": {
          "values": [
            "1",
            "2"
          ]
        }
      }
    }
  }
}

Mapping:
{
  "posts": {
    "mappings": {
      "posts": {
        "dynamic_templates": [{
          "blog": {
            "mapping": {
              "index": "analyzed"
            },
            "path_match": "blog.*",
            "path_unmatch": "*.medias.*"
          }
        }, {
          "ids": {
            "mapping": {
              "index": "not_analyzed",
              "type": "string"
            },
            "match": "_id|base_id",
            "match_pattern": "regex"
          }
        }],
        "_all": {
          "enabled": false
        },
        "properties": {
          "query": {
            "properties": {
              "filtered": {
                "properties": {
                  "filter": {
                    "properties": {
                      "ids": {
                        "properties": {
                          "values": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "query": {
                    "properties": {
                      "match_all": {
                        "type": "object"
                      }
                    }
                  }
                }
              },
              "match_all": {
                "type": "object"
              }
            }
          },
          "source": {
            "dynamic": "true",
            "properties": {
              "post": {
                "dynamic": "true",
                "properties": {
                  "_id": {
                    "type": "string",
                    "index": "not_analyzed"
                  },
                  "base_id": {
                    "type": "string",
                    "index": "not_analyzed"
                  }
                }
              }
            }
          },
          "blog": {
            "properties": {
              "post": {
                "properties": {
                  "_id": {
                    "type": "string"
                  },
                  "notes": {
                    "properties": {
                      "main": {
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          }
                        }
                      },
                      "cart": {
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "category": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}


A: {
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": {
            "terms": {
              "_id": [1, 2]
            }
          },
          "must_not": {
            "terms": {
              "post.notes.main.category": [
                "other"
              ]
            }
          }
        }
      }
    }
  }
}

