Filter on array entries?

(Ben Woosley) #1

Hey Guys,

I have some articles that are associated with groups, and I want to select
all articles that have a certain group id associated, but elasticsearch
isn't returning the results in a query. I've tried a number of different
approaches and I hope someone here can tell me what I'm doing wrong.

Here's the relevant part of the mapping (in standard elasticsearch-rails

has_many :groups

mapping do
indexes :group_ids # this is just an array of ids

def as_indexed_json(options={})
as_json(methods: [

Here's are some filter queries that fail to select the articles associated
with a certain group:
filter: { term: { 'group_ids' => '8c7664ac-9f0a-41b1-824b-d6a23170bb3e' }
query: {
filtered: {
query: { match_all: {} },
filter: { term: { 'group_ids' =>
'8c7664ac-9f0a-41b1-824b-d6a23170bb3e' } }

And here's a query that does select them:
query: {
match: { 'group_ids' => '8c7664ac-9f0a-41b1-824b-d6a23170bb3e' }

Can someone tell me why this is failing? I'm running against elasticsearch
1.2.1 and elasticsearch-rails 0.1.4.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit

(system) #2