[Koha-bugs] [Bug 31652] Add geo-search

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Aug 11 21:17:12 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31652

Thomas Klausner <domm at plix.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #153720|0                           |1
        is obsolete|                            |

--- Comment #7 from Thomas Klausner <domm at plix.at> ---
Created attachment 154388
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=154388&action=edit
Bug 31652: Add geo-search

This patch adds geosearch to Koha (using Elasticsearch 7). ElasticSearch
search_mappings get new types to store lat/lon, which can be indexed
from MARC 034$s and 034$t. There is a small change to the DB to allow a
new value in search_field.type ENUM.

The QueryBuilder is extended to allow for building advanced
ElasticSearch Querys (eg geo_distance) that cannot be represented in a
simple string query.

We added a new SystemPreference `GeoSearchEnabled`. If it is set to
`true`, we show a new advanced search field that allows for input of lat/lng
and distance (radius). On the search result page, a we render a map
using leaflet.js with pins for each found item. Therefor we also added a
new api endpoint that returns lat/lng for each biblio in the selection.

Test Plan:

* make sure you're running ElasticSearch 7
  (eg via `curl http://es:9200?pretty | grep number`)
* apply patch
* Set system preference "SearchEngine" to "Elasticsearch"
* got to a Framework, check Editor for 034$s and 034$t and save
* got to some books (in the correct framework) and enter some lat and lon into
034$s and 034$t (for example lat=48.216, lon=16.395)
* Run the elasticsearch indexer, maybe limited on the books you edited (-bn 123
-bn 456):
  misc/search_tools/rebuild_elasticsearch.pl -b -v
* You can check if the indexing worked by inspecting the document in
elasticsearch:
  * get the biblionumber (eg 123)
  * curl http://es:9200/koha_kohadev_biblios/_doc/123?pretty | grep -A5
geolocation
  * You should get back a JSON fragment containing the lat/lon you stored
* You can query elasticsearch directly:
  * Run the following curl command, but adapt the value for lat/lng and/or the
distance (in meters)
  * curl -X GET "http://es:9200/koha_kohadev_biblios/_search?pretty" -H
'Content-Type: application/json' -d '{"query":
{"bool":{"must":{"match_all":{}},"filter":{"geo_distance":{"distance":100000,"geolocation":{"lat":48.2,"lon":16.4}}}}}}'
* To run the search via Koha:
  * Set system preference "GeoSearchEnabled" to "true"
  * got to OPAC / Advanced Search
  * There is a new input box "Geographic Search" where you can enter
lat/long/radius, for example lat=48.2, lng=16.3, distance=100km
  * On the search result page a map is shown with pins for each found
biblioitem

Sponsored-by: ZAMG - Zentralanstalt für Meterologie und Geodynamik, Austria -
https://www.zamg.ac.at/

Authors: Mark Hofstetter <mark at hofstetter.at>, Thomas Klausner <domm at plix.at>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list