-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for query facets #62
Comments
Yes, as you've discovered I've kind of just ignored this. But it should definitely be supported. I have not quite decided on how to do the implementation, but it should be implemented in a way that feels natural concerning the other faceting options (by utilising the It would probably also be useful to be able to override the declared Since we already declare the Ex: field_options = {
"firstname": {"query": ["robin*", "joh*"]}
} Next, when constructing the query in the This way we can support multiple query facets per field, as well as keeping the API simple and familiar. Any inputs are appreciated! |
Another solution could be to introduce a new Meta attribute |
When thinking about it I prefer the latter solution. Even if it requires the introduction of another Meta attribute, it's more declarative and better describes the action which will be taken. |
I've started an implementation of the For this example, I need a method of generating custom date facets. They are rendered as follows: "queries": {
"availability_archived": {
"count": 2,
"query": "end:<=now",
"narrow_url": "http://cd.local:8008/api/v1/search/all/facets/?content_type=courserun&selected_query_facets=availability_archived&selected_query_facets=availability_starting_soon&q=python"
},
"availability_starting_soon": {
"count": 4,
"query": "start:[now TO now+60d]",
"narrow_url": "http://cd.local:8008/api/v1/search/all/facets/?content_type=courserun&selected_query_facets=availability_starting_soon&q=python"
}
}, I do not like the fact that the filtering is dependent on the view, as this is a violation of separation of concerns. Initially, I declared the facets in the view; but, opted to change this after reading your message, @rhblind. I'd be curious to hear the history behind defining facets on the serializer rather than the view. |
Great, I'll have a look at what you've come up with!
I'm not quite sure I get what you mean. The As for "defining facets on the serializer" I take it that you mean the If you have strong feelings for putting them on the view rather on the serializer, I'm willing to discuss it. But I think we should avoid breaking the API unless we have to... |
Another thing I came to think about is that declaring query facets in a list/tuple is probably ambiguous, since each search backend has its own syntax for doing |
My comment is about the fact that filters depend on the views' serializers to build the queryset. I'm not recommending that change now; but, I do find it rather strange that the serializer affects the queryset. I generally prefer my serializers to be rather dumb, focusing solely on converting Python data to some other data type (e.g. JSON). Regarding declaration of query facets, I am using a dict similar to the existing facets: class CourseRunFacetSerializer(BaseHaystackFacetSerializer):
serialize_objects = True
class Meta:
field_queries = {
'availability_current': {'query': 'start:<now AND end:>now'},
} In this example |
Ah, of course. Sorry was a bit tired this morning =) Well, yes I agree, it's not optimal to put them on the serializer. But I'm also not too keen on doing a breaking API change when I'm in an It seems like you're in the process of making something work here and I really appreciate it, so thanks! |
Add support for customizable query facets.
The text was updated successfully, but these errors were encountered: