-
Notifications
You must be signed in to change notification settings - Fork 84
Closed
Description
I'm new to Python & Django, but pretty handy with Solr. I'm trying to facet on a query instead of just a field, so here's what I added:
diff --git a/sunburnt/search.py b/sunburnt/search.py
index 3eb0b6b..8aebaad 100644
--- a/sunburnt/search.py
+++ b/sunburnt/search.py
@@ -251,12 +251,13 @@ class LuceneQuery(object):
class SolrSearch(object):
- option_modules = ('query_obj', 'filter_obj', 'paginator', 'more_like_this', 'highlighter', 'faceter', 'sorter')
+ option_modules = ('query_obj', 'filter_obj', 'facet_obj', 'paginator', 'more_like_this', 'highlighter', 'faceter', 'sorter')
def __init__(self, interface):
self.interface = interface
self.schema = interface.schema
self.query_obj = LuceneQuery(self.schema, 'q')
self.filter_obj = LuceneQuery(self.schema, 'fq')
+ self.facet_obj = LuceneQuery(self.schema, 'facet.query')
self.paginator = PaginateOptions(self.schema)
self.more_like_this = MoreLikeThisOptions(self.schema)
self.highlighter = HighlightOptions(self.schema)
@@ -283,6 +284,10 @@ class SolrSearch(object):
def query(self, *args, **kwargs):
self.query_obj.add(args, kwargs)
return self
+
+ def facet_query(self, *args, **kwargs):
+ self.facet_obj.add(args, kwargs)
+ return self
def exclude(self, *args, **kwargs):
self.query(~self.Q(*args, **kwargs))
Am I close? It works, but I still need to add facet_by("somefield") to get the actual facet=true added to the query. Not sure if I should try to merge that code with the above or leave them separate and just use that workaround?
execute().facet_counts.facet_queries
works, though, so it's aware of facet_queries at least in theory? Is there another way I should be using facet queries?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels