Skip to content

Commit

Permalink
Changed ranking mode to SPH04 - boosts the matches for exact query. F…
Browse files Browse the repository at this point in the history
…ixed parsing viewbox as sout,west,north,east.
  • Loading branch information
MartinMikita committed May 25, 2016
1 parent b75ddf1 commit 6f0e1e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions web/templates/answer.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<td>
{% if col in row %}
{{ row[col] }}
{% if col == 'boundingbox' %}
<br>{{ row['lon'] }}, {{ row['lat'] }}
{% endif %}
{% endif %}
</td>
{% endfor %}
Expand Down
9 changes: 5 additions & 4 deletions web/websearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

Expand All @@ -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])
Expand Down

0 comments on commit 6f0e1e1

Please sign in to comment.