Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lugensa/sunburnt
...
head fork: lugensa/sunburnt
  • 6 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
Commits on Nov 01, 2013
@florianpilz florianpilz Start to add support for hierarchical facetting (pivot). 62f3477
Commits on Nov 04, 2013
@florianpilz florianpilz Finish support for facet.pivot queries.
- fix option output from list to concatenated string
- new query command 'pivot_by'
- option 'mincount' is recognized for facet.pivot.mincount, rather f.FIELD.facet.pivot.mincount
- remove all other options
45441fe
@florianpilz florianpilz Add facet.pivot to output of facet_counts. 875b143
@florianpilz florianpilz Fix broken test. 18baf01
@florianpilz florianpilz Update Changelog. 9479d72
@delijati delijati Merge branch 'master' of https://github.com/florianpilz/sunburnt into…
… florianpilz-master

Conflicts:
	Changelog
45631b4
View
1  .gitignore
@@ -5,3 +5,4 @@ MANIFEST
build
dist
docs/_build
+*.egg-info/
View
68 Changelog
@@ -1,37 +1,51 @@
-* 0.7 : unreleased
-0.8 (unreleased)
-
-
-- Nothing changed yet.
+0.7.1lu (unreleased)
+--------------------
+- Add support for hierarchical facet queryies, i.e. facet.pivot. (@florianpilz)
0.7lu (2013-07-02)
- - Provide default string-based field for schema field types unknown to
- - Escape forward slash characters for compatibility with Solr 4.0 (@davidjb)
- Sunburnt. (@davidjb)
- - Fix handling of queries with ``boost_relevancy`` applied - boost was
- previously lost in some cases. (@davidjb)
- - Ensure 'more like this' results are transformed using a query's
- execute() `constructor`, as are normal query results. (@davidjb)
+------------------
+
+- Provide default string-based field for schema field types unknown to
+
+- Escape forward slash characters for compatibility with Solr 4.0 (@davidjb)
+ Sunburnt. (@davidjb)
+
+- Fix handling of queries with ``boost_relevancy`` applied - boost was
+ previously lost in some cases. (@davidjb)
+
+- Ensure 'more like this' results are transformed using a query's
+ execute() `constructor`, as are normal query results. (@davidjb)
+
+0.6 (2012-01-01)
+----------------
+
+- Change license to MIT/X11
+
+- Integrate with Django Paginator (thanks @rlskoeser)
+
+- Add UUIDField support
+
+- Add MLT Handler support (thanks @ogrisel)
+
+0.5 (2011-05-18)
+----------------
+
+- Add proper documentation
+
+- Add field_limit() option (thanks, @danaspiegel)
-* 0.6 : 2012-01-01
- - Change license to MIT/X11
- - Integrate with Django Paginator (thanks @rlskoeser)
- - Add UUIDField support
- - Add MLT Handler support (thanks @ogrisel)
+- Add basic support for new Solr-3.1 datatypes
+- Add support for __any queries (thanks, @skarab)
-* 0.5 : 2011-05-18
- - Add proper documentation
- - Add field_limit() option (thanks, @danaspiegel)
- - Add basic support for new Solr-3.1 datatypes
- - Add support for __any queries (thanks, @skarab)
- - Add experimental JSON output module
+- Add experimental JSON output module
- - Rationalize data normalization and quoting codepaths, fixing several bugs along the way
- - Fixes for correct serialization of complex nested query objects
+- Rationalize data normalization and quoting codepaths, fixing several bugs along the way
+- Fixes for correct serialization of complex nested query objects
-* 0.4 : 2011-01-04
+0.4 (2011-01-04)
+----------------
- - First release on PyPi
+- First release on PyPi
View
2  sunburnt/schema.py
@@ -641,7 +641,7 @@ def __str__(self):
class SolrFacetCounts(object):
- members= ["facet_dates", "facet_fields", "facet_queries"]
+ members= ["facet_dates", "facet_fields", "facet_queries", "facet_pivot"]
def __init__(self, **kwargs):
for member in self.members:
setattr(self, member, kwargs.get(member, ()))
View
34 sunburnt/search.py
@@ -363,7 +363,8 @@ class BaseSearch(object):
"""Base class for common search options management"""
option_modules = ('query_obj', 'filter_obj', 'paginator',
'more_like_this', 'highlighter', 'faceter',
- 'sorter', 'facet_querier', 'field_limiter',)
+ 'sorter', 'facet_querier', 'field_limiter',
+ 'pivoter')
result_constructor = dict
@@ -373,6 +374,7 @@ def _init_common_modules(self):
self.paginator = PaginateOptions(self.schema)
self.highlighter = HighlightOptions(self.schema)
self.faceter = FacetOptions(self.schema)
+ self.pivoter = FacetPivotOptions(self.schema)
self.sorter = SortOptions(self.schema)
self.field_limiter = FieldLimitOptions(self.schema)
self.facet_querier = FacetQueryOptions(self.schema)
@@ -432,6 +434,11 @@ def facet_by(self, field, **kwargs):
newself.faceter.update(field, **kwargs)
return newself
+ def pivot_by(self, fields, **kwargs):
+ newself = self.clone()
+ newself.pivoter.update(fields, **kwargs)
+ return newself
+
def facet_query(self, *args, **kwargs):
newself = self.clone()
newself.facet_querier.update(self.Q(*args, **kwargs))
@@ -762,6 +769,31 @@ def field_names_in_opts(self, opts, fields):
opts["facet.field"] = sorted(fields)
+class FacetPivotOptions(Options):
+ option_name = "facet.pivot"
+ opts = {
+ "mincount":lambda self, x: int(x) >= 0 and int(x) or self.invalid_value(),
+ }
+
+ def __init__(self, schema, original=None):
+ self.schema = schema
+ if original is None:
+ self.fields = collections.defaultdict(dict)
+ else:
+ self.fields = copy.copy(original.fields)
+
+ def field_names_in_opts(self, opts, fields):
+ opts["facet"] = True
+ if fields:
+ field_opts = {}
+ for field in fields:
+ field_opts = dict(field_opts.items() + self.fields[field].items())
+ del(self.fields[field])
+ self.fields[None] = field_opts
+ opts["facet.pivot"] = ','.join(sorted(fields))
+
+
+
class HighlightOptions(Options):
option_name = "hl"
opts = {"snippets":int,
View
14 sunburnt/test_search.py
@@ -16,7 +16,7 @@
HAS_MX_DATETIME = False
from .schema import SolrSchema, SolrError
-from .search import SolrSearch, MltSolrSearch, PaginateOptions, SortOptions, FieldLimitOptions, FacetOptions, HighlightOptions, MoreLikeThisOptions, params_from_dict
+from .search import SolrSearch, MltSolrSearch, PaginateOptions, SortOptions, FieldLimitOptions, FacetOptions, FacetPivotOptions, HighlightOptions, MoreLikeThisOptions, params_from_dict
from .strings import RawString
from .sunburnt import SolrInterface
@@ -227,8 +227,8 @@ class MockInterface(object):
}
if HAS_MX_DATETIME:
good_query_data['query'] += \
- ([], {"date_field":mx.DateTime.DateTime(2009, 1, 1)},
- [("q", u"date_field:2009-01-01T00\\:00\\:00Z")])
+ (([], {"date_field":mx.DateTime.DateTime(2009, 1, 1)},
+ [("q", u"date_field:2009\\-01\\-01T00\\:00\\:00Z")]),)
def check_query_data(method, args, kwargs, output):
solr_search = SolrSearch(interface)
@@ -308,6 +308,14 @@ def test_bad_query_data():
({"fields":["int_field", "text_field"], "prefix":"abc", "limit":3},
{"facet":True, "facet.field":["int_field", "text_field"], "f.int_field.facet.prefix":"abc", "f.int_field.facet.limit":3, "f.text_field.facet.prefix":"abc", "f.text_field.facet.limit":3, }),
),
+ FacetPivotOptions:(
+ ({"fields":["text_field"]},
+ {"facet":True, "facet.pivot":"text_field"}),
+ ({"fields":["int_field", "text_field"]},
+ {"facet":True, "facet.pivot":"int_field,text_field"}),
+ ({"fields":["int_field", "text_field"], "mincount":2},
+ {"facet":True, "facet.pivot":"int_field,text_field", "facet.pivot.mincount":2}),
+ ),
SortOptions:(
({"field":"int_field"},
{"sort":"int_field asc"}),

No commit comments for this range

Something went wrong with that request. Please try again.