Filter output of term facet - not input

Yea, lose the facet filter. Move it up as another "must" clause to
your boolean query filter and don't use an "or" filter, use a
TermsFilter as that will give you better performance.

On Thu, Feb 21, 2013 at 2:31 PM, ripplekhera ripplekhera@gmail.com wrote:

Matt, thank you very much for the regex suggestion. It is awesome. This is a
sample of my resulted query. I think providing both a query filter and facet
filter might be overkill so I might remove it, but it works:

{
"size" : 0,
"query" : {
"filtered" : {
"query" : {
"bool" : {
"must" : {
"range" : {"created_at" : {"from" : "now-30d","to" : "now",
"include_lower" : true,
"include_upper" : true
}
}
}
}
},
"filter" : {
"or" : {
"filters" : [ {"term" : {"tags" :
"userid_50fd9f5373e13056e76f9e7f"}},
{"term" : {"tags" : "userid_51007ef3e4b0a99e8714a9e9"}},
{"term" : {"tags" : "userid_50e228cae4b05800e6ea1ef2"}},
{"term" : {"tags" : "userid_50fdaee7e4b05ced2d76710e"}},
{"term" : {"tags" : "userid_50c6dfdee4b030a63367a6e7"}},
{"term" : {"tags" : "userid_50f4680ce4b080e3535795dc"}},
{"term" : {"tags" : "userid_50ddf00ae4b000084a2dc057"}},
{"term" : { "tags" : "userid_50c6e080e4b030a63367a6e9" }},
{"term" : {"tags" : "userid_50f06636e4b0560131c8730c" }} ]
}
}
}
},
"fields" : [ "id", "tags" ],
"facets" : {
"usageFacet" : {
"terms" : {
"field" : "tags",
"size" : 9,
"regex" : "userid_.*$"
},
"facet_filter" : {
"or" : {
"filters" : [ {"term" : {"tags" :
"userid_50fd9f5373e13056e76f9e7f"}},
{"term" : {"tags" : "userid_51007ef3e4b0a99e8714a9e9"}},
{"term" : {"tags" : "userid_50e228cae4b05800e6ea1ef2"}},
{"term" : {"tags" : "userid_50fdaee7e4b05ced2d76710e"}},
{"term" : {"tags" : "userid_50c6dfdee4b030a63367a6e7"}},
{"term" : {"tags" : "userid_50f4680ce4b080e3535795dc"}},
{"term" : {"tags" : "userid_50ddf00ae4b000084a2dc057"}},
{"term" : { "tags" : "userid_50c6e080e4b030a63367a6e9" }},
{"term" : {"tags" : "userid_50f06636e4b0560131c8730c" }} ]
}
}
}
}
}

Another option could have been to use the query facet. But this one serves
better.
The query facet is available at :
Elasticsearch Platform — Find real-time answers at scale | Elastic

On Tuesday, February 19, 2013 2:09:25 PM UTC-8, Matt Weber wrote:

Actually you have two options:

  1. Use you can exclude tags you don't want counted (ie. microsoft,
    kinect, etc)
  2. Use a regex pattern for the terms you want included.

#2 would be my choice because it looks like you can do a basic
expression such as "username_.*$" or even looking for your specific
users "userid_5114575ae4b0cb71b6654321|userid_5114575ae4b0cb71b6654320"

See the section on excluding terms and regex patterns here:

Elasticsearch Platform — Find real-time answers at scale | Elastic

Hope this helps.

Thanks,
Matt Weber

On Tue, Feb 19, 2013 at 1:43 PM, AlexR royt...@gmail.com wrote:

Maybe I am missing something but why not add filter on user to your
query then you will limit your resultset and facets will only have the user
you want

--
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 elasticsearc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.