Help newbie: make dynamic aggregation by category


#1

I am new to Elasticsearch and try to learn it from docs.
Now using Django-haystack 2.5.0 https://django-haystack.readthedocs.io and Elasticsearch 1.7.3

I need to implement dynamic facets: user have a form where he put
names of facets, and after search is performed he is able to filter by
these categories with sidebar filter form.

What i read in docs is facets implemented on fields, for example dates or authors, then filtering is done like this:

Tom (345)
Mary (218)
...

But this is not what i want. I have in my models only 1 text field and facets are aggregated dynamically during search.
So, for movie texts i want facets like this:

Detective (633)
Comedy (237)
...

and each genre is calculated by search query:

Detective

text: _"Columbo is an American television series starring Peter _
_Falk as Columbo, a homicide detective with the Los Angeles Police _
_Department.[2][3] The character and show, created by William Link and _
Richard Levinson, popularized the inverted detective story format, which
_ begins by showing the commission of the crime and its perpetrator; the _
series therefore has no "whodunit" element. The plot revolves around how
_ a perpetrator whose identity is already known to the audience will _
_finally be caught and exposed (which the show's writers called a _
"howcatchem," rather than a "whodunit")."

to detect category Detective and Comedy we search:
(cop | murder | crime | ...) and (story | ...)
or
(joke| lol | ...) and (story | ...)
or
....

And the same search strings for other categories - so i need big query at once with named parts
I understand that explanations are unclear, but really not sure on what part of docs describe this.

  1. Second question - i have read about term vectors to get list of words that found in text.
    How to setup this with Python's django-haystack lib? No such details in docs

(system) #2