Skip to content

Commit

Permalink
search no longer filters names with synonyms from multiple synonym li…
Browse files Browse the repository at this point in the history
…sts (#518)

Signed-off-by: Kial Jinnah <[email protected]>
  • Loading branch information
kialj876 authored and katiemcgoff committed Feb 7, 2019
1 parent ab28550 commit 5be5931
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 10 additions & 3 deletions api/namex/analytics/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ def get_conflict_results(cls, name, bucket, start=0, rows=100):
for item in result['response']['docs']:
if item['name'] not in seen_ordered_names:
ordered_names.append({'name_info': item, 'stems': []})
for missed in missed_names:
current_app.logger.error('MISSED results: ', missed)

if len(missed_names) > 0:
current_app.logger.error('MISSED results: {}'.format(missed_names))
final_names_list = []

# order based on alphabetization of swapped in synonyms
Expand Down Expand Up @@ -635,7 +636,13 @@ def _get_synonym_list(cls, token):
# Not sure what it is, pass it up.
raise http_error

return json.load(connection)[1][0].split(',')
results = json.load(connection)
synonym_list = []
# in case a token is part of multiple synonym lists
for synonyms in results[1]:
synonym_list += synonyms.split(',')

return synonym_list

# Look up each token in name, and if it is in the synonyms then we need to search for it separately.
@classmethod
Expand Down
17 changes: 15 additions & 2 deletions api/tests/python/end_points/test_synonym_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,19 +486,20 @@ def test_strips_stop_words(client, jwt, app, criteria, seed):
query=criteria,
expected_list=[seed]
)

@integration_postgres_solr
@integration_synonym_api
@integration_solr
@pytest.mark.parametrize("query, ordered_list", [
('TESTING ORDER DEVELOPMENTS SYNONYMS', ['----TESTING ORDER DEVELOPMENTS SYNONYMS - PROXIMITY SEARCH',
('TESTING ORDER DEVELOPMENT SYNONYMS', ['----TESTING ORDER DEVELOPMENT SYNONYMS - PROXIMITY SEARCH',
'TESTING ORDER DEVELOPMENT SYNONYMS',
'TESTING ORDER CONSTRUCTION SYNONYMS',
'TESTING ORDER STRUCTURE SYNONYMS',
]),
])
def test_order(client, jwt, app, query, ordered_list):
# for loop didn't work for seeding so manual
seed_database_with(client, jwt, 'TESTING ORDER CONSTRUCTION SYNONYMS', id='1', source='2', clear=False)
seed_database_with(client, jwt, 'TESTING ORDER CONSTRUCTION SYNONYMS', id='1', source='2')
seed_database_with(client, jwt, 'TESTING ORDER DEVELOPMENT SYNONYMS', id='2', source='4', clear=False)
seed_database_with(client, jwt, 'TESTING ORDER STRUCTURE SYNONYMS', id='3', source='3', clear=False)
verify_order(client, jwt, query=query, expected_order=ordered_list)
Expand All @@ -518,3 +519,15 @@ def test_order(client, jwt, app, query, ordered_list):
def test_stems(client, jwt, app, query, stems):
verify_stems(client, jwt, query=query, stems=stems)

@integration_postgres_solr
@integration_synonym_api
@integration_solr
@pytest.mark.parametrize("query, expected_list", [
('PACIFIC FASTFOOD', ['PACIFIC TAKEOUT', 'PACIFIC CONCESSION']),
])
def test_synonyms_match_on_all_synonym_lists_(client, jwt, app, query, expected_list):
# some synonyms are part of multiple lists so check that they return matches on both
seed_database_with(client, jwt, 'PACIFIC TAKEOUT', id='1', source='2')
seed_database_with(client, jwt, 'PACIFIC CONCESSION', id='2', source='2', clear=False)
verify_synonym_match(client, jwt, query=query, expected_list=expected_list)

0 comments on commit 5be5931

Please sign in to comment.