nanterre: add settings for search thresholds (fixes #22507)

This commit is contained in:
Benjamin Dauvergne 2018-03-14 11:01:45 +01:00 committed by Thomas NOEL
parent 14ae6c90ed
commit 89ec65e116
2 changed files with 4 additions and 4 deletions

View File

@ -167,8 +167,8 @@ class SearchView(APIView):
try:
threshold = float(request.GET.get('threshold', ''))
except ValueError:
threshold = 0.2
search = utils.PersonSearch(limit=threshold)
threshold = getattr(settings, 'ZOO_NANTERRE_SEARCH_THRESHOLD', 0.13)
search = utils.PersonSearch(limit=threshold, base_limit=threshold)
if 'q' in request.GET:
search = search.search_query(request.GET['q'])
else:

View File

@ -20,6 +20,7 @@ import datetime
from django.db.transaction import atomic
from django.db.models.query import Q
from django.utils.timezone import now
from django.conf import settings
from zoo.utils import strip_accents
from zoo.zoo_data.models import Entity
@ -31,9 +32,8 @@ from .utils import pair_sort, PersonSearch
def find_duplicates(limit=None, base_limit=None, queryset=None, days=None, count=None, ids=None,
progression=False):
# Define search space
limit = limit or 0.75
limit = limit or getattr(settings, 'ZOO_NANTERRE_DUPLICATES_THRESHOLD', 0.7)
base_limit = base_limit or limit / 2.0
'''Search for duplicate entities based on a list of field paths'''
qs = queryset or Entity.objects.all()
qs = qs.filter(schema__slug='individu')
if days: