Skip to content

Commit

Permalink
Merge pull request #158 from hinashi/fixed/entry_search_result
Browse files Browse the repository at this point in the history
Fixed the result being different depending on the hint_attr_value of search_entries
  • Loading branch information
userlocalhost authored Jun 24, 2021
2 parents 61238f0 + a9f1a84 commit 538187e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions airone/lib/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)) + ".*"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions entry/tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 538187e

Please sign in to comment.