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

WebSearch: add middle name wild card #127

Open
wants to merge 1 commit into
base: prod
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/websearch/lib/search_engine_query_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,9 @@ def _create_author_search_pattern_from_fuzzy_name_dict(self, fuzzy_name):
for i in range(1,len(author_name)):
search_pattern += ' or ' + self._EA_TAG + "\"%s, %s\"" % (author_surname, author_name[0:i])

if not author_middle_name:
search_pattern += ' or ' + self._A_TAG + '"' + author_surname + ', ' + author_name[0] + ' *"'

search_pattern += ' or %s"%s, *"' % (self._A_TAG, full_search)

return search_pattern
Expand Down
14 changes: 11 additions & 3 deletions modules/websearch/lib/search_engine_query_parser_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,17 @@ def test_stisc(self):
"""Test whole convert/parse stack: SQPP.parse_query(STISC.convert_query('find a richter, burton and t quark'))"""
self.assertEqual(self.parser.parse_query(self.converter.convert_query('find a richter, burton and t quark')),
['+',
'author:"richter, burton*" | exactauthor:"richter, b *" | exactauthor:"richter, b" | exactauthor:"richter, bu" | exactauthor:"richter, bur" | exactauthor:"richter, burt" | exactauthor:"richter, burto" | author:"richter, burton, *"',
'author:"richter, burton*" | exactauthor:"richter, b *" | exactauthor:"richter, b" | exactauthor:"richter, bu" | exactauthor:"richter, bur" | exactauthor:"richter, burt" | exactauthor:"richter, burto" | author:"richter, b *" | author:"richter, burton, *"',
'+', 'title:quark'])

def test_expand_lastname_with_parse_query(self):
"""Test one more convert/parse_query """
self.assertEqual(self.parser.parse_query(self.converter.convert_query("find a o'connell, heath")),
['+', 'author:"o\'connell, heath*" | exactauthor:"o\'connell, h *" | exactauthor:"o\'connell, h" | exactauthor:"o\'connell, he" | exactauthor:"o\'connell, hea" | exactauthor:"o\'connell, heat" | author:"o\'connell, h *" | author:"o\'connell, heath, *"'])
self.assertEqual(self.parser.parse_query(self.converter.convert_query("find a o'connell, heath b")),
['+', 'author:"o\'connell, heath* b*" | exactauthor:"o\'connell, h b" | exactauthor:"o\'connell, he b" | exactauthor:"o\'connell, hea b" | exactauthor:"o\'connell, heat b"'])


def test_stisc_not_vs_and_not1(self):
"""Parse stack parses "find a ellis, j and not a enqvist" == "find a ellis, j not a enqvist" """
self.assertEqual(self.parser.parse_query(self.converter.convert_query('find a ellis, j and not a enqvist')),
Expand Down Expand Up @@ -435,7 +443,7 @@ def test_author_full_initial(self):

def test_author_full_first(self):
"""SPIRES search syntax - find a ellis, john"""
invenio_search = 'author:"ellis, john*" or exactauthor:"ellis, j *" or exactauthor:"ellis, j" or exactauthor:"ellis, jo" or exactauthor:"ellis, joh" or author:"ellis, john, *"'
invenio_search = 'author:"ellis, john*" or exactauthor:"ellis, j *" or exactauthor:"ellis, j" or exactauthor:"ellis, jo" or exactauthor:"ellis, joh" or author:"ellis, j *" or author:"ellis, john, *"'
spires_search = 'find a ellis, john'
self._compare_searches(invenio_search, spires_search)

Expand Down Expand Up @@ -489,7 +497,7 @@ def test_refersto_author_multi_name(self):

def test_refersto_author_multi_name_no_quotes(self):
"""SPIRES search syntax - find a ellis and refersto author parke, sj"""
inv_search = 'author:ellis refersto:(author:"parke, sj*" or exactauthor:"parke, s *" or exactauthor:"parke, s" or author:"parke, sj, *")'
inv_search = 'author:ellis refersto:(author:"parke, sj*" or exactauthor:"parke, s *" or exactauthor:"parke, s" or author:"parke, s *" or author:"parke, sj, *")'
spi_search = "find a ellis and refersto author parke, sj"
self._compare_searches(inv_search, spi_search)

Expand Down