From a9f1a84273456bab4afbd3ecf821ab87d889f3b8 Mon Sep 17 00:00:00 2001 From: hinashi Date: Thu, 24 Jun 2021 12:10:15 +0900 Subject: [PATCH] Fixed the result being different depending on the hint_attr_value of search_entries --- airone/lib/elasticsearch.py | 4 ++-- entry/tests/test_model.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/airone/lib/elasticsearch.py b/airone/lib/elasticsearch.py index 7d610625d..3d05a7011 100644 --- a/airone/lib/elasticsearch.py +++ b/airone/lib/elasticsearch.py @@ -190,8 +190,8 @@ def make_query(hint_entity_ids, hint_attrs, hint_attr_value, entry_name, or_matc 'nested': { 'path': 'attr', 'query': { - 'wildcard': { - 'attr.value': "*" + str(hint_attr_value) + "*" + 'regexp': { + 'attr.value': ".*" + _get_regex_pattern(str(hint_attr_value)) + ".*" } } } diff --git a/entry/tests/test_model.py b/entry/tests/test_model.py index 221bf0761..55ef074f4 100644 --- a/entry/tests/test_model.py +++ b/entry/tests/test_model.py @@ -1598,6 +1598,11 @@ def test_search_entries(self): self.assertEqual(ret['ret_count'], 1) self.assertEqual(ret['ret_values'][0]['entry']['name'], 'e-0') + # check whether keyword would be insensitive case + ret = Entry.search_entries(user, [entity.id], hint_attr_value='FOO-0') + self.assertEqual(ret['ret_count'], 1) + self.assertEqual(ret['ret_values'][0]['entry']['name'], 'e-0') + def test_search_entries_with_hint_referral(self): user = User.objects.create(username='hoge')