From 7269ab0a2b73437bdc2cd93a4551842634204a6d Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 28 May 2013 17:11:11 +0200 Subject: [PATCH 01/18] added handling for None values (needed for date fields) --- Changelog | 1 + sunburnt/schema.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 1a1c579..d396bf7 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ * 0.7 : unreleased + - Added handling for None values (@jod) - Provide default string-based field for schema field types unknown to - Escape forward slash characters for compatibility with Solr 4.0 (@davidjb) Sunburnt. (@davidjb) diff --git a/sunburnt/schema.py b/sunburnt/schema.py index 3dffb8a..7df9b10 100644 --- a/sunburnt/schema.py +++ b/sunburnt/schema.py @@ -562,9 +562,14 @@ def doc(self, doc): if not doc: return self.DOC() else: - return self.DOC(*reduce(operator.add, - [self.fields(name, values) - for name, values in doc.items()])) + # XXX remove all None fields this is needed for adding date fields + fields = [] + for name, values in doc.items(): + if values is None: + doc.pop(name) + continue + fields.append(self.fields(name, values)) + return self.DOC(*reduce(operator.add, fields)) def add(self, docs): if hasattr(docs, "items") or not hasattr(docs, "__iter__"): From 502f173c7dac0455f799f258b661bc3e38cb96f5 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 2 Jul 2013 15:39:15 +0200 Subject: [PATCH 02/18] updated version --- sunburnt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sunburnt/__init__.py b/sunburnt/__init__.py index 60d32bf..f9c00de 100644 --- a/sunburnt/__init__.py +++ b/sunburnt/__init__.py @@ -3,6 +3,6 @@ from .strings import RawString from .sunburnt import SolrError, SolrInterface -__version__ = '0.6' +__version__ = '0.7' __all__ = ['RawString', 'SolrError', 'SolrInterface'] From ca0e84b067220aa22592b970f0cfcc464d0ed363 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 2 Jul 2013 16:01:12 +0200 Subject: [PATCH 03/18] updated version --- setup.py | 6 ++---- sunburnt/__init__.py | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 39e6701..9563362 100644 --- a/setup.py +++ b/setup.py @@ -2,13 +2,11 @@ import distutils.core, os, re -version_number_re = "\s*__version__\s*=\s*((\"([^\"]|\\\\\")*\"|'([^']|\\\\')*'))" -version_file = os.path.join(os.path.dirname(__file__), 'sunburnt', '__init__.py') -version_number = re.search(version_number_re, open(version_file).read()).groups()[0][1:-1] +version = '0.7' distutils.core.setup( name='sunburnt', - version=version_number, + version=version, description='Python interface to Solr', author='Toby White', author_email='toby@timetric.com', diff --git a/sunburnt/__init__.py b/sunburnt/__init__.py index f9c00de..b4bcef5 100644 --- a/sunburnt/__init__.py +++ b/sunburnt/__init__.py @@ -3,6 +3,4 @@ from .strings import RawString from .sunburnt import SolrError, SolrInterface -__version__ = '0.7' - __all__ = ['RawString', 'SolrError', 'SolrInterface'] From 8f3f8da3a4bacbf8ec0fe7376a0a733eb4422d35 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 2 Jul 2013 16:01:41 +0200 Subject: [PATCH 04/18] Preparing release 0.7lu --- Changelog | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d396bf7..357de3b 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ * 0.7 : unreleased - - Added handling for None values (@jod) +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) diff --git a/setup.py b/setup.py index 9563362..2a35eac 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import distutils.core, os, re -version = '0.7' +version = '0.7lu' distutils.core.setup( name='sunburnt', From d9164455b2b01cc84ba5467ea7324bc3b8d65c19 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 2 Jul 2013 16:02:22 +0200 Subject: [PATCH 05/18] Back to development: 0.8 --- Changelog | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 357de3b..b1f3738 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,10 @@ * 0.7 : unreleased +0.8 (unreleased) + + +- Nothing changed yet. + + 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) diff --git a/setup.py b/setup.py index 2a35eac..3b57159 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import distutils.core, os, re -version = '0.7lu' +version = '0.8.dev0' distutils.core.setup( name='sunburnt', From 62f34777830a72c6ca9d3ffdfa60733e755aad36 Mon Sep 17 00:00:00 2001 From: Florian Pilz Date: Fri, 1 Nov 2013 14:42:55 +0100 Subject: [PATCH 06/18] Start to add support for hierarchical facetting (pivot). --- .gitignore | 1 + sunburnt/search.py | 25 +++++++++++++++++++++++++ sunburnt/test_search.py | 8 +++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 825a5ee..8cd0c7a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ MANIFEST build dist docs/_build +*.egg-info/ diff --git a/sunburnt/search.py b/sunburnt/search.py index d90a9bf..22619a5 100644 --- a/sunburnt/search.py +++ b/sunburnt/search.py @@ -762,6 +762,31 @@ def field_names_in_opts(self, opts, fields): opts["facet.field"] = sorted(fields) +class FacetPivotOptions(Options): + option_name = "facet" + opts = {"prefix":unicode, + "sort":[True, False, "count", "index"], + "limit":int, + "offset":lambda self, x: int(x) >= 0 and int(x) or self.invalid_value(), + "mincount":lambda self, x: int(x) >= 0 and int(x) or self.invalid_value(), + "missing":bool, + "method":["enum", "fc"], + "enum.cache.minDf":int, + } + + 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): + if fields: + opts["facet.pivot"] = sorted(fields) + + + class HighlightOptions(Options): option_name = "hl" opts = {"snippets":int, diff --git a/sunburnt/test_search.py b/sunburnt/test_search.py index e804ac4..1c90046 100644 --- a/sunburnt/test_search.py +++ b/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 @@ -308,6 +308,12 @@ 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"]}) + ), SortOptions:( ({"field":"int_field"}, {"sort":"int_field asc"}), From 45441fe9ed06cfe63f73bf544850b076d2f3c321 Mon Sep 17 00:00:00 2001 From: Florian Pilz Date: Mon, 4 Nov 2013 10:50:23 +0100 Subject: [PATCH 07/18] 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 --- sunburnt/search.py | 31 +++++++++++++++++++------------ sunburnt/test_search.py | 6 ++++-- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/sunburnt/search.py b/sunburnt/search.py index 22619a5..13191d4 100644 --- a/sunburnt/search.py +++ b/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)) @@ -763,16 +770,10 @@ def field_names_in_opts(self, opts, fields): class FacetPivotOptions(Options): - option_name = "facet" - opts = {"prefix":unicode, - "sort":[True, False, "count", "index"], - "limit":int, - "offset":lambda self, x: int(x) >= 0 and int(x) or self.invalid_value(), - "mincount":lambda self, x: int(x) >= 0 and int(x) or self.invalid_value(), - "missing":bool, - "method":["enum", "fc"], - "enum.cache.minDf":int, - } + 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 @@ -782,8 +783,14 @@ def __init__(self, schema, original=None): self.fields = copy.copy(original.fields) def field_names_in_opts(self, opts, fields): + opts["facet"] = True if fields: - opts["facet.pivot"] = sorted(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)) diff --git a/sunburnt/test_search.py b/sunburnt/test_search.py index 1c90046..83dcfcf 100644 --- a/sunburnt/test_search.py +++ b/sunburnt/test_search.py @@ -310,9 +310,11 @@ def test_bad_query_data(): ), FacetPivotOptions:( ({"fields":["text_field"]}, - {"facet":True, "facet.pivot":["text_field"]}), + {"facet":True, "facet.pivot":"text_field"}), ({"fields":["int_field", "text_field"]}, - {"facet":True, "facet.pivot":["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"}, From 875b143077b4663d92dbf070d0fdf685617a12c3 Mon Sep 17 00:00:00 2001 From: Florian Pilz Date: Mon, 4 Nov 2013 10:51:27 +0100 Subject: [PATCH 08/18] Add facet.pivot to output of facet_counts. --- sunburnt/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sunburnt/schema.py b/sunburnt/schema.py index 3dffb8a..19f0fb0 100644 --- a/sunburnt/schema.py +++ b/sunburnt/schema.py @@ -636,7 +636,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, ())) From 18baf015f7b415ceef670e39a92924d2bc629764 Mon Sep 17 00:00:00 2001 From: Florian Pilz Date: Mon, 4 Nov 2013 10:56:54 +0100 Subject: [PATCH 09/18] Fix broken test. --- sunburnt/test_search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sunburnt/test_search.py b/sunburnt/test_search.py index 83dcfcf..deb4719 100644 --- a/sunburnt/test_search.py +++ b/sunburnt/test_search.py @@ -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) From 9479d72730949f6671c95fdc6cf52f24b2accf07 Mon Sep 17 00:00:00 2001 From: Florian Pilz Date: Mon, 4 Nov 2013 11:27:32 +0100 Subject: [PATCH 10/18] Update Changelog. --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index 1a1c579..4f84e58 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ * 0.7 : unreleased + - Add support for hierarchical facet queryies, i.e. facet.pivot. (@florianpilz) - Provide default string-based field for schema field types unknown to - Escape forward slash characters for compatibility with Solr 4.0 (@davidjb) Sunburnt. (@davidjb) From 21a8b73cef14c8b54a306c7fe1d38630c11a9031 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Mon, 4 Nov 2013 14:27:49 +0100 Subject: [PATCH 11/18] Preparing release 0.7.1lu --- Changelog | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 9905554..9f19810 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -0.7.1lu (unreleased) +0.7.1lu (2013-11-04) -------------------- - Add support for hierarchical facet queryies, i.e. facet.pivot. (@florianpilz) diff --git a/setup.py b/setup.py index 3b57159..96d1170 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import distutils.core, os, re -version = '0.8.dev0' +version = '0.7.1lu' distutils.core.setup( name='sunburnt', From 2ad5782a0117d3686a846890879cc07ded9fe30b Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Mon, 4 Nov 2013 14:28:45 +0100 Subject: [PATCH 12/18] Back to development: 0.8 --- Changelog | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 9f19810..b2f17a1 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +0.8 (unreleased) +---------------- + +- Nothing changed yet. + + 0.7.1lu (2013-11-04) -------------------- diff --git a/setup.py b/setup.py index 96d1170..3b57159 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import distutils.core, os, re -version = '0.7.1lu' +version = '0.8.dev0' distutils.core.setup( name='sunburnt', From 2659ce64ea0401bceaaa6ac945b7892ec4a40a26 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 17 Dec 2013 13:39:16 +0100 Subject: [PATCH 13/18] added PostingsHighlighter --- .gitignore | 1 + Changelog | 6 +++++- setup.py | 6 +++--- sunburnt/dates.py | 2 ++ sunburnt/search.py | 42 +++++++++++++++++++++++++++++++++++++++-- sunburnt/test_schema.py | 4 ++-- sunburnt/test_search.py | 37 ++++++++++++++++++++++++++++++++++-- 7 files changed, 88 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 8cd0c7a..62e3d88 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build dist docs/_build *.egg-info/ +env/ diff --git a/Changelog b/Changelog index 4de1bcf..3f89b06 100644 --- a/Changelog +++ b/Changelog @@ -1,7 +1,11 @@ 0.8 (unreleased) ---------------- -- Nothing changed yet. +- Fixed tests. + [jod] + +- Use setuptools in setup.py. + [jod] 0.7.1lu (2013-11-04) -------------------- diff --git a/setup.py b/setup.py index 3b57159..e0c277f 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,17 @@ #!/usr/bin/env python -import distutils.core, os, re +from setuptools import setup version = '0.8.dev0' -distutils.core.setup( +setup( name='sunburnt', version=version, description='Python interface to Solr', author='Toby White', author_email='toby@timetric.com', packages=['sunburnt'], - requires=['httplib2', 'lxml', 'pytz'], + install_requires=['httplib2', 'lxml', 'pytz', 'setuptools'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', diff --git a/sunburnt/dates.py b/sunburnt/dates.py index fd58976..7896703 100644 --- a/sunburnt/dates.py +++ b/sunburnt/dates.py @@ -1,6 +1,7 @@ from __future__ import absolute_import import datetime, math, re, warnings +import pytz try: import mx.DateTime @@ -55,6 +56,7 @@ def datetime_from_w3_datestring(s): del d['tzd_sign'] del d['tzd_hour'] del d['tzd_minute'] + d['tzinfo'] = pytz.utc try: dt = datetime_factory(**d) + tz_delta except DateTimeRangeError: diff --git a/sunburnt/search.py b/sunburnt/search.py index 70e7897..df3b7b7 100644 --- a/sunburnt/search.py +++ b/sunburnt/search.py @@ -376,8 +376,8 @@ def add_boost(self, kwargs, boost_score): 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', + 'more_like_this', 'highlighter', 'postings_highlighter', + 'faceter', 'sorter', 'facet_querier', 'field_limiter', 'pivoter') result_constructor = dict @@ -387,6 +387,7 @@ def _init_common_modules(self): self.filter_obj = LuceneQuery(self.schema, u'fq') self.paginator = PaginateOptions(self.schema) self.highlighter = HighlightOptions(self.schema) + self.postings_highlighter = PostingsHighlightOptions(self.schema) self.faceter = FacetOptions(self.schema) self.pivoter = FacetPivotOptions(self.schema) self.sorter = SortOptions(self.schema) @@ -463,6 +464,11 @@ def highlight(self, fields=None, **kwargs): newself.highlighter.update(fields, **kwargs) return newself + def postings_highlight(self, fields=None, **kwargs): + newself = self.clone() + newself.postings_highlighter.update(fields, **kwargs) + return newself + def mlt(self, fields, query_fields=None, **kwargs): newself = self.clone() newself.more_like_this.update(fields, query_fields, **kwargs) @@ -840,6 +846,38 @@ def field_names_in_opts(self, opts, fields): opts["hl.fl"] = ",".join(sorted(fields)) +class PostingsHighlightOptions(Options): + + option_name = "hl" + opts = {"snippets": int, + "tag.pre": unicode, + "tag.post": unicode, + "tag.ellipsis": unicode, + "defaultSummary": bool, + "encoder": unicode, + "score.k1": float, + "score.b": float, + "score.pivot": float, + "bs.type": unicode, + "bs.language": unicode, + "bs.country": unicode, + "bs.variant": unicode, + "maxAnalyzedChars": unicode, + "multiValuedSeperatorChar": unicode + } + + 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): + if fields: + opts["hl.fl"] = ",".join(sorted(fields)) + + class MoreLikeThisOptions(Options): option_name = "mlt" opts = {"count":int, diff --git a/sunburnt/test_schema.py b/sunburnt/test_schema.py index a8c9875..1f66355 100644 --- a/sunburnt/test_schema.py +++ b/sunburnt/test_schema.py @@ -51,7 +51,7 @@ "2009-07-23T03:24:34.1Z": datetime.datetime(2009, 07, 23, 3, 24, 34, 100000, pytz.utc), "2009-07-23T03:24:34.123Z": - datetime.datetime(2009, 07, 23, 3, 24, 34, 123000, pytz.utc) + datetime.datetime(2009, 07, 23, 3, 24, 34, 122999, pytz.utc) } def check_solr_date_from_date(s, date, canonical_date): @@ -59,7 +59,7 @@ def check_solr_date_from_date(s, date, canonical_date): check_solr_date_from_string(s, canonical_date) def check_solr_date_from_string(s, date): - assert solr_date(s)._dt_obj == date + assert solr_date(s)._dt_obj == date, "Unequal representations of %r: %r" % (solr_date(s)._dt_obj, date) def test_solr_date_from_pydatetimes(): for k, v in samples_from_pydatetimes.items(): diff --git a/sunburnt/test_search.py b/sunburnt/test_search.py index deb4719..b03b435 100644 --- a/sunburnt/test_search.py +++ b/sunburnt/test_search.py @@ -16,7 +16,10 @@ HAS_MX_DATETIME = False from .schema import SolrSchema, SolrError -from .search import SolrSearch, MltSolrSearch, PaginateOptions, SortOptions, FieldLimitOptions, FacetOptions, FacetPivotOptions, HighlightOptions, MoreLikeThisOptions, params_from_dict +from .search import (SolrSearch, MltSolrSearch, PaginateOptions, SortOptions, + FieldLimitOptions, FacetOptions, FacetPivotOptions, + HighlightOptions, MoreLikeThisOptions, params_from_dict, + PostingsHighlightOptions) from .strings import RawString from .sunburnt import SolrInterface @@ -338,6 +341,35 @@ def test_bad_query_data(): ({"fields":["int_field", "text_field"], "snippets":3, "fragsize":5}, {"hl":True, "hl.fl":"int_field,text_field", "f.int_field.hl.snippets":3, "f.int_field.hl.fragsize":5, "f.text_field.hl.snippets":3, "f.text_field.hl.fragsize":5}), ), + PostingsHighlightOptions:( + ({"fields":"int_field"}, + {"hl":True, "hl.fl":"int_field"}), + ({"fields":["int_field", "text_field"]}, + {"hl":True, "hl.fl":"int_field,text_field"}), + ({"snippets":3}, + {"hl":True, "hl.snippets":3}), + ({"fields":["int_field", "text_field"], "snippets":1, + "tag.pre":"<em>", "tag.post": "<em>", + "tag.ellipsis": "...", "defaultSummary": True, "encoder": "simple", + "score.k1": 1.2, "score.b": 0.75, "score.pivot": 87, + "bs.type": "SENTENCE", "maxAnalyzedChars": 10000,}, + {'f.text_field.hl.score.b': 0.75, 'f.int_field.hl.encoder': u'simple', + 'f.int_field.hl.tag.pre': u'<em>', 'f.text_field.hl.tag.pre': + u'<em>', 'f.text_field.hl.defaultSummary': True, + 'f.text_field.hl.tag.post': u'<em>', 'f.text_field.hl.bs.type': + u'SENTENCE', 'f.int_field.hl.tag.ellipsis': u'...', + 'f.text_field.hl.score.k1': 1.2, 'f.text_field.hl.tag.ellipsis': + u'...', 'f.int_field.hl.score.pivot': 87.0, + 'f.int_field.hl.tag.post': u'<em>', 'f.int_field.hl.bs.type': + u'SENTENCE', 'f.int_field.hl.score.b': 0.75, + 'f.text_field.hl.maxAnalyzedChars': u'10000', 'hl': True, + 'f.text_field.hl.encoder': u'simple', 'hl.fl': + 'int_field,text_field', 'f.int_field.hl.snippets': 1, + 'f.text_field.hl.snippets': 1, 'f.int_field.hl.maxAnalyzedChars': + u'10000', 'f.int_field.hl.score.k1': 1.2, + 'f.int_field.hl.defaultSummary': True, 'f.text_field.hl.score.pivot': + 87.0}), + ), MoreLikeThisOptions:( ({"fields":"int_field"}, {"mlt":True, "mlt.fl":"int_field"}), @@ -367,7 +399,8 @@ def test_bad_query_data(): def check_good_option_data(OptionClass, kwargs, output): optioner = OptionClass(schema) optioner.update(**kwargs) - assert optioner.options() == output + assert optioner.options() == output, "Unequal: %r, %r" % ( + optioner.options(), output) def test_good_option_data(): for OptionClass, option_data in good_option_data.items(): From 6ffcb39bdaab6a0d5323b4cc0da0b96731eff833 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 17 Dec 2013 15:55:33 +0100 Subject: [PATCH 14/18] updated changelog --- Changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog b/Changelog index 3f89b06..034f312 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,9 @@ - Use setuptools in setup.py. [jod] +- Added https://wiki.apache.org/solr/PostingsHighlighter + [jod] + 0.7.1lu (2013-11-04) -------------------- From 06a1411f9087243ed286cc83627083945a02537d Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 17 Dec 2013 16:54:56 +0100 Subject: [PATCH 15/18] added boundaryScanner releated options --- Changelog | 3 +++ sunburnt/search.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 034f312..e2b64d4 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,9 @@ 0.8 (unreleased) ---------------- +- Added boundaryScanner options to HighlightOptions. + [jod] + - Fixed tests. [jod] diff --git a/sunburnt/search.py b/sunburnt/search.py index df3b7b7..bf91cf7 100644 --- a/sunburnt/search.py +++ b/sunburnt/search.py @@ -832,7 +832,13 @@ class HighlightOptions(Options): "highlightMultiTerm":bool, "regex.slop":float, "regex.pattern":unicode, - "regex.maxAnalyzedChars":int + "regex.maxAnalyzedChars":int, + "boundaryScanner": unicode, + "bs.maxScan": unicode, + "bs.chars": unicode, + "bs.type": unicode, + "bs.language": unicode, + "bs.country": unicode, } def __init__(self, schema, original=None): self.schema = schema From 5458460c49d89c3c558895d56b8a98efcfc79fbf Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 17 Dec 2013 16:56:55 +0100 Subject: [PATCH 16/18] Preparing release 0.8lu --- Changelog | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index e2b64d4..02ddb9b 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,5 @@ -0.8 (unreleased) ----------------- +0.8lu (2013-12-17) +------------------ - Added boundaryScanner options to HighlightOptions. [jod] diff --git a/setup.py b/setup.py index e0c277f..ceab811 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup -version = '0.8.dev0' +version = '0.8lu' setup( name='sunburnt', From 4bb943ec83960863191791bc972b5e5c81237b95 Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 17 Dec 2013 16:57:33 +0100 Subject: [PATCH 17/18] Back to development: 0.8.1lu --- Changelog | 6 ++++++ setup.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 02ddb9b..ac4150d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,9 @@ +0.8.1lu (unreleased) +-------------------- + +- Nothing changed yet. + + 0.8lu (2013-12-17) ------------------ diff --git a/setup.py b/setup.py index ceab811..a1b6069 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup -version = '0.8lu' +version = '0.8.1lu.dev0' setup( name='sunburnt', From dbae48ac5b5435618e6429ed815072b6946c53dc Mon Sep 17 00:00:00 2001 From: Josip Delic Date: Tue, 11 Mar 2014 11:26:18 +0100 Subject: [PATCH 18/18] added coverage --- setup.cfg | 6 ++++++ sunburnt/tests/__init__.py | 1 + 2 files changed, 7 insertions(+) create mode 100644 setup.cfg create mode 100644 sunburnt/tests/__init__.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b4688ce --- /dev/null +++ b/setup.cfg @@ -0,0 +1,6 @@ +[nosetests] +match=^test +nocapture=1 +cover-package=sunburnt +with-coverage=1 +cover-erase=1 diff --git a/sunburnt/tests/__init__.py b/sunburnt/tests/__init__.py new file mode 100644 index 0000000..792d600 --- /dev/null +++ b/sunburnt/tests/__init__.py @@ -0,0 +1 @@ +#