0

I have an multi-tenant application that uses index aliases with filters. There is just one issue... when I use facet('tags') { terms :tags, all_terms: true } it returns all terms for the complete index and not the ones that match the current tenant.

Is where a simple way arround this issue (except generating an index per customer)?

Example: http://pastie.org/5400685

spas
  • 1,914
  • 14
  • 21

1 Answers1

0

It looks like there is a bug in how elasticsearch treats all_terms in facets on filtering aliases. But solution for your issue is simple, just remove all_terms: true and run your facet on the match_all or *:* query.

imotov
  • 28,277
  • 3
  • 90
  • 82
  • Do you mean a facet filter with `match_all`? – spas Nov 21 '12 at 13:18
  • No, I meant do what you are already doing, just remove all_terms: true. Here is an example: https://gist.github.com/6aaac09bb35ea45ea209 – imotov Nov 21 '12 at 13:50
  • Yes, but then you don't get the terms with 0 matches. – spas Nov 21 '12 at 13:58
  • Oh, I see what you are saying now. So, you want to execute a query using filtering alias, but you want to also get terms that exist in the results limited by only by alias filter, but might have 0 hits in the result limited by both alias filter and your query. That's tricky. Not sure if it's possible to do in a single request without fixing https://github.com/elasticsearch/elasticsearch/issues/2423 first. You can do it in two requests though. First, get total list of facet in alias using *:* and then get counts using your query. – imotov Nov 21 '12 at 14:21
  • yeah, thought so... too bad. – spas Nov 21 '12 at 14:39