ES 2.0 terms filter with execution

Hi!

I have articles (and a bunch of other stuff) with tags. In my search I aggregate these tags and provide them as filters. Previously I could use a terms filter with execution and to make it filter on all selected tags. It looked like this (a bit simplified):

  {
    :body=>
    { :query=>
      { :filtered=>
        { :query=>
          {
            :multi_match=>
            {
              :query=> "Something",
              :fields=> ["*.original^4", "*.stemmed", "*.partial", "tag.name.original^30", "tag.name.lowercased^30", "department.title", "department_title", "colleague.full_name"],
              :cutoff_frequency=>0.001
            }
          },
          :filter=>
          {
            :terms=> {"tags.id"=> [5, 8], :execution=>:and }
          }
        }
      },
      :aggregations=>
      {
        :tag_ids=>
        {
          :terms=>
          {
            :field=>"tags.id"
          }
        }
      },
      :_source=> ["id"],
      :from=>0, :size=>10
    }, :index=>["my_index"], :type=>[]
  }

However, now that I'm trying to use ES 2.0 instead of 1.X the tag id filter does not work anymore. The execution part is ignored and it always matches on any of the specified ids instead of on all of them.

It seems this functionality was "esoteric" enough to have it removed: https://github.com/elastic/elasticsearch/pull/10531/files#diff-45578110da805e8e218ec718a8351525L52

However, I can't find any other way of doing this kind of filtering.

Does anyone have an idea on how to get this filter working on ES 2.0?

EDIT:

Also, the tags are indexed nested on the articles.

{
  title,
  body,
 ....
  tags: [
    {
       1.
       SomeTag
    },
    {
       2,
       AnotherTag
     }
  ]
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.