Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'postatum-98399258_fulltext_bug' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jstoiko committed Jul 17, 2015
2 parents 42680d5 + aae62df commit a97defd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions nefertari/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ def build_qs(params, _raw_terms='', operator='AND'):
terms.append('%s:%s' % (k, v))

terms = sorted([term for term in terms if term])
_terms = (' %s ' % operator).join(terms) + _raw_terms

_terms = (' %s ' % operator).join(terms)
if _raw_terms:
add = (' AND ' + _raw_terms) if _terms else _raw_terms
_terms += add
return _terms


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def bootstrap(config):
config.include('nefertari.elasticsearch')

if Settings.asbool('enable_get_tunneling'):
log.warning('GET tunneling enabled')
config.add_tween('nefertari.tweens.get_tunneling')

def _route_url(request, route_name, *args, **kw):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_build_dunder_key(self):
assert qs == 'foo:1 OR foo:2'

def test_build_raw_terms(self):
qs = es.build_qs(dictset({'foo': [1, 2]}), _raw_terms=' AND qoo:1')
qs = es.build_qs(dictset({'foo': [1, 2]}), _raw_terms='qoo:1')
assert qs == 'foo:1 OR foo:2 AND qoo:1'

def test_build_operator(self):
Expand Down Expand Up @@ -489,12 +489,12 @@ def test_get_by_ids_not_found_not_raise(self, mock_mget):
def test_build_search_params_no_body(self):
obj = es.ES('Foo', 'foondex')
params = obj.build_search_params(
{'foo': 1, 'zoo': 2, 'q': ' AND q:5', '_limit': 10}
{'foo': 1, 'zoo': 2, 'q': '5', '_limit': 10}
)
assert sorted(params.keys()) == sorted([
'body', 'doc_type', 'from_', 'size', 'index'])
assert params['body'] == {
'query': {'query_string': {'query': 'foo:1 AND zoo:2 AND q:5'}}}
'query': {'query_string': {'query': 'foo:1 AND zoo:2 AND 5'}}}
assert params['index'] == 'foondex'
assert params['doc_type'] == 'foo'

Expand Down

0 comments on commit a97defd

Please sign in to comment.