Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 19 additions and 7 deletions.
  1. +1 −1  setup.py
  2. +10 −4 sunburnt/search.py
  3. +8 −2 sunburnt/tests/test_search.py
View
2  setup.py
@@ -22,7 +22,7 @@
'httplib2',
'lxml',
'pytz',
- #'egenix-mx-base',
+ 'egenix-mx-base',
'nose',
'coverage',
],
View
14 sunburnt/search.py
@@ -84,8 +84,12 @@ def serialize_term_queries(self, terms):
s = []
for name, value_set in terms.items():
if name:
- s += [u'%s:%s' % (name, self.to_query(value))
- for value in value_set]
+ tmp = [u'%s:%s' % (name, self.to_query(value))
+ for value in value_set]
+ if name == '*':
+ tmp = [u'%s:%s' % (name, value)
+ for value in value_set]
+ s += tmp
else:
s += [self.to_query(value) for value in value_set]
return sorted(s)
@@ -100,8 +104,10 @@ def to_solr(self, value):
return unicode(value)
def to_query(self, value):
- ret = sunburnt.strings.RawString(self.to_solr(value)
- ).escape_for_lqs_term()
+ ret = sunburnt.strings.RawString(
+ self.to_solr(value)).escape_for_lqs_term()
+ if isinstance(value, sunburnt.strings.WildcardString):
+ ret = value.escape_for_lqs_term()
return ret
range_query_templates = {
View
10 sunburnt/tests/test_search.py
@@ -17,7 +17,7 @@
SortOptions, FieldLimitOptions, FacetOptions,
GroupOptions, HighlightOptions,
MoreLikeThisOptions, params_from_dict)
-from sunburnt.strings import RawString
+from sunburnt.strings import WildcardString
from sunburnt.sunburnt import SolrInterface
from .test_sunburnt import MockConnection, MockResponse
from nose.tools import assert_equal
@@ -210,7 +210,7 @@ class MockInterface(object):
([], {'string_field': ['hello world', 'goodbye, cruel world']},
[("q", u"string_field:goodbye,\\ cruel\\ world AND string_field:hello\\ world")]),
# Raw strings
- ([], {'string_field': RawString("abc*???")},
+ ([], {'string_field': "abc*???"},
[("q", "string_field:abc\\*\\?\\?\\?")]),
],
}
@@ -419,6 +419,12 @@ def check_bad_option_data(OptionClass, kwargs):
[('q', u'blah AND (def OR ghi)^1.5')]),
(lambda q: q.query("blah").query(q.Q("def", ~q.Q("pqr") | q.Q("mno")) ** 1.5),
[('q', u'blah AND (def AND ((*:* AND NOT pqr) OR mno))^1.5')]),
+ #wildcard
+ (lambda q: q.query("blah").query(q.Q(WildcardString("def*"),
+ ~q.Q(miu=WildcardString("pqr*")) | q.Q("mno")) ** 1.5),
+ [('q', 'blah AND (def* AND ((*:* AND NOT miu:pqr*) OR mno))^1.5')]),
+ (lambda q: q.query("blah").query(q.Q("def*", ~q.Q(miu="pqr*") | q.Q("mno")) ** 1.5),
+ [('q', 'blah AND (def\\* AND ((*:* AND NOT miu:pqr\\*) OR mno))^1.5')]),
# And boost_relevancy
(lambda q: q.query("blah").boost_relevancy(1.5, int_field=3),
[('q', u'blah OR (blah AND int_field:3^1.5)')]),

No commit comments for this range

Something went wrong with that request. Please try again.