summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-07-02 20:22:10 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-13 18:26:03 +0200
commit07b79e0a6d32eb6d6b6d8dfbdec99e2c31ae5c2b (patch)
tree371b9f82f5a988972b3773327d3949a95dbb15e0
parent31873237b90c588f49f403721a382df59719ca1b (diff)
downloadIshtar-07b79e0a6d32eb6d6b6d8dfbdec99e2c31ae5c2b.tar.bz2
Ishtar-07b79e0a6d32eb6d6b6d8dfbdec99e2c31ae5c2b.zip
Full text search: open search in facets (refs #4180)
-rw-r--r--archaeological_operations/tests.py8
-rw-r--r--ishtar_common/views_item.py5
2 files changed, 10 insertions, 3 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 1480eb502..f67ce5adc 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1585,6 +1585,13 @@ class OperationSearchTest(TestCase, OperationInitTest):
result = json.loads(response.content)
self.assertEqual(result['recordsTotal'], 3)
+ # open search '*'
+ search = {'search_vector': u'{}="{}*"'.format(search_q, neo.label[:3])}
+ response = c.get(reverse('get-operation'), search)
+ self.assertEqual(response.status_code, 200)
+ result = json.loads(response.content)
+ self.assertEqual(result['recordsTotal'], 2)
+
# non hierarchic search
search_q = unicode(
pgettext("key for text search (no accent, no spaces)", u"remain")
@@ -1595,7 +1602,6 @@ class OperationSearchTest(TestCase, OperationInitTest):
result = json.loads(response.content)
self.assertEqual(result['recordsTotal'], 1)
-
def create_relations(self):
rel1 = models.RelationType.objects.create(
symmetrical=True, label='Include', txt_idx='include')
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index a2cc0762c..675c36575 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -751,8 +751,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
if val.startswith(u'"') and val.startswith(u'"'):
# manage search text by label
- if u"%" in val:
+ if u"*" in val:
suffix = "label__icontains"
+ val = val.replace(u'*', u"")
else:
suffix = "label__iexact"
val = val[1:-1]
@@ -788,9 +789,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
for val in values:
if not val.endswith(u'"') or not val.startswith(u""):
continue
- query = val[1:-1]
suffix = "__label__icontains" if u"%" in val else \
"__label__iexact"
+ query = val[1:-1].replace(u'*', u"")
if not reqs:
reqs = Q(**{base_k + suffix: query})
else: