From 6f0e1e1e674d934d65a7bd102c62353c3b57f19c Mon Sep 17 00:00:00 2001 From: MartinMikita Date: Wed, 25 May 2016 18:01:48 +0200 Subject: [PATCH] Changed ranking mode to SPH04 - boosts the matches for exact query. Fixed parsing viewbox as sout,west,north,east. --- web/templates/answer.html | 3 +++ web/websearch.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/templates/answer.html b/web/templates/answer.html index 12b74e6..0aa3912 100644 --- a/web/templates/answer.html +++ b/web/templates/answer.html @@ -24,6 +24,9 @@ {% if col in row %} {{ row[col] }} + {% if col == 'boundingbox' %} +
{{ row['lon'] }}, {{ row['lat'] }} + {% endif %} {% endif %} {% endfor %} diff --git a/web/websearch.py b/web/websearch.py index 986de19..99c1c33 100755 --- a/web/websearch.py +++ b/web/websearch.py @@ -57,10 +57,11 @@ def process_query(index, query, query_filter, start=0, count=0): cl.SetServer(host, port) cl.SetConnectTimeout(2.0) # float seconds cl.SetLimits(start, count) #offset, limit, maxmatches=0, cutoff=0 + cl.SetRankingMode(SPH_RANK_SPH04) # cl.SetMatchMode(SPH_MATCH_EXTENDED2) # default setting cl.SetSortMode(SPH_SORT_EXTENDED, '@relevance DESC, importance DESC') cl.SetFieldWeights({ - 'name': 50, + 'name': 500, 'display_name': 1, }) @@ -73,10 +74,10 @@ def process_query(index, query, query_filter, start=0, count=0): if 'viewbox' in query_filter and query_filter['viewbox'] is not None: bbox = query_filter['viewbox'].split(',') - # longtitude, west, east - lon = [float(bbox[0]), float(bbox[2])] # latitude, south, north - lat = [float(bbox[1]), float(bbox[3])] + lat = [float(bbox[0]), float(bbox[2])] + # longtitude, west, east + lon = [float(bbox[1]), float(bbox[3])] # Filter on lon lat now cl.SetFilterFloatRange('lon', lon[0], lon[1]) cl.SetFilterFloatRange('lat', lat[0], lat[1])