Skip to content
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
6 changes: 4 additions & 2 deletions api/namex/resources/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,8 @@ def get(nr, choice, *args, **kwargs):
@api.route('/possible-conflicts/<string:name>', methods=['GET', 'OPTIONS'])
class PossibleConflicts(Resource):
START = 0
ROWS = 1000
ROWS = 50
STRICT = False

@staticmethod
@cors.crossdomain(origin='*')
Expand All @@ -1459,7 +1460,8 @@ class PossibleConflicts(Resource):
def get(name):
start = request.args.get('start', PossibleConflicts.START)
rows = request.args.get('rows', PossibleConflicts.ROWS)
results = SolrHlpers.get_possible_conflicts(name, start=start, rows=rows)
strict = request.args.get('strict', PossibleConflicts.STRICT)
results = SolrHlpers.get_possible_conflicts(name, start=start, rows=rows, strict=strict)
return make_response(jsonify(results), 200)


Expand Down
5 changes: 3 additions & 2 deletions api/namex/services/solr/solr_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ def search_nrs(cls, query_value, start=0, rows=10):


@classmethod
def get_possible_conflicts(cls, name, start=0, rows=100):
def get_possible_conflicts(cls, name, start=0, rows=100, strict=True):
request_json = {
'query': { 'value': name },
'start': start,
'rows': rows
'rows': rows,
'strict': strict
}

token = cls._get_bearer_token()
Expand Down
9 changes: 5 additions & 4 deletions api/namex/services/solr/solr_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _conflicts_post_process(cls, q_data, query_name):
exact_matches = []
similar_matches = []
histories = []

total_results = q_data.get('searchResults', {}).get('totalResults', 0)
for rcd in q_data.get('searchResults', {}).get('results', []):
nm = cls._get_name_without_designation(rcd.get('name'))
if nm == query_name:
Expand All @@ -85,7 +85,8 @@ def _conflicts_post_process(cls, q_data, query_name):
return {
'names': similar_matches,
'exactNames': exact_matches,
'histories': histories}
'histories': histories,
'total': total_results}

def normalize_words(word):
"""
Expand Down Expand Up @@ -139,13 +140,13 @@ def _get_name_without_designation(cls, name):
return ' '.join(filtered_words)

@classmethod
def get_possible_conflicts(cls, name, start=0, rows=100):
def get_possible_conflicts(cls, name, start=0, rows=100, strict=True):
# q_name = cls._name_pre_processing(name)
q_name = name.lower().strip()
# Keep the raw query for Solr ranking/boosts. Skip-word filtering for
# match prep happens in namex-solr-api via DESIGNATIONS.
stripped_name = cls._get_name_without_designation(q_name)

candidates = SolrClient.get_possible_conflicts(q_name, start, rows)
candidates = SolrClient.get_possible_conflicts(q_name, start, rows, strict)
return cls._conflicts_post_process(candidates, stripped_name)