CottageLabs / facetview2

a pure javascript frontend for ElasticSearch search indices.
MIT License
78 stars 31 forks source link

Add support for extra_predefined_filters #1

Closed mihaibivol closed 9 years ago

mihaibivol commented 9 years ago

I am currently investigating an upgrade from okfn facetview to facetview2.

For the update to be possible, we use predefined filters expressed in ES syntax. As our filters are somewhat complex, it's hard to express them as (facet, filter) pairs and it would be easier to just directly add them to the query. Also, the predefined filters rely on some date fields which can't be added in the current version (as range filters).

emanuil-tolev commented 9 years ago

@mihaibivol sounds like a reasonable option to include! If you've traced it down to where you'd like these extra_predefined_filters added to the query I'd be very happy to merge a PR.

mihaibivol commented 9 years ago

@mihaibivol sounds like a reasonable option to include! If you've traced it down to where you'd like these extra_predefined_filters added to the query I'd be very happy to merge a PR.

To work as OKFN's facetview, the extra_predefined_filters list could be added to the "must" query option list:

{"query":{"filtered":
{"filter":{"bool":{"must":[{"term":{"topic":"Agriculture"}}] +
$EXTRA_PREDEFINED_FILTERS}},

"query":{"query_string":{"query":"ok","default_operator":"OR"}}}},
                          .....
mihaibivol commented 9 years ago

@emanuil-tolev I just saw that the fixed_filters option behaves exactly as I intended. Will use this.