Jump to content

running Algolia filter geolocation with radius - in a huge dataset


dil_bert
 Share

Recommended Posts

hello dear phpfreaks, 

 

running Algolia filter geolocation with radius - in a huge dataset

 

i have a dataset - that looks like so

@id    @type    @lon    @lat    amenity    name    addr:postcode    addr:city    addr:street    addr:housenumber    contact:website    website    contact:email
287819214    node    11.4237356    48.1353946    school    Förderschule und Heilpädagogische Tagesstätte    81249    München    Köferinger Straße    20            
703266518    node    11.5746643    48.1387135    school    EAM School of International Business                            
1187338076    node    11.6799856    48.0835519    childcare    Little Giants    81739    München    Asenweg    18       https://www.littlegiants.de/en/centers/munich  
1720213613    node    11.5178775    48.0677475    kindergarten    Kindertagesstätte Rasselbande    81479    München    Wilhelm-Leibl-Straße    40       http://www.rasselbandekindertagesstaette.de/  
2473262857    node    11.4545099    48.1342614    childcare    Joki Kinderbetreuung    81241    München    Haidelweg    46       https://www.joki-kinderbetreuung.de/kinderkrippe-und-kindergarten-pasing/  
2501713471    node    11.6578738    48.0784633    school    VHS Kursort    85579    Neubiberg    Floriansanger    3            
2598851386    node    11.4735866    48.0912428    nursing_home    "Seniorenzentrum ""Marie-Anne Clauss"""        München    Luganoweg    8       https://www.asb-casa-vital.de/muenchen.html  
2685212812    node    11.5454459    48.0735744    kindergarten    Hänsel und Gretel    81545    München    Wunderhornstraße    7b            
2696585853    node    11.6572337    48.0789303    school    Musikschule Neubiberg                            
2960337347    node    11.6989158    48.1164575    kindergarten    Allegro Private Vorschule    81827    München    Dompfaffweg    10            
3345528112    node    11.7017383    48.1213520    kindergarten    Gemeindekindergarten Gronsdorf    85540    Haar    Sofienstraße    4            
3345528113    node    11.7156962    48.1081492    kindergarten    Kinderhaus    85540    Haar    Hans-Pinsel-Straße    9b            
4476584953    node    11.5148195    48.0654931    kindergarten    Kinderhaus St. Gabriel Nord                       http://www.kinderhaus.st.gabrielsolln.de/  
4670738346    node    11.5144853    48.0643890    kindergarten    Klosterfrösche                       http://www.klosterfroesche.de  
4670738347    node    11.5152132    48.0646958    kindergarten    Klosterspatzen                       https://klosterspatzen.de/  
4670738348    node    11.5147286    48.0648090    kindergarten    Kinderhaus St. Gabriel Süd                       http://www.kinderhaus.st.gabrielsolln.de/  

i want to run a search with Alglia for full text search in my dataset. I'want to be able to search and filter all objects. especially i want to use 'aroundRadius', 

'aroundRadius' and also 'aroundLatLng' should return all the data without caring about the location.
 The filed _geoloc with lat and lng also exist in my data - of course - see above. 

this.index.search(query,{

      filters: filters,
      aroundLatLng: location,
      aroundRadius: radius

    }).then((data) => {      
      console.log(data);
    })

Do I need any special configuration for Indice or the syntax is wrong? I followed this data-man-pages

https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/how-to/filter-results-around-a-location/?client=python

Filter Results Around a Location

[
 {
    "objectID": "3797",
    "name": "John F Kennedy Intl",
    "city": "New York",
    "country": "United States",
    "iata_code": "JFK",
    "_geoloc": {
      "lat": 40.639751,
      "lng": -73.778925
    },
    "links_count": 911
  }
]

To tell Algolia where each record is located, we need to have the latitude and longitude stored in the _geoloc attribute.
You can download the dataset here. Have look at how to import it in Algolia here.

Initialize the client#
from algoliasearch.search_client import SearchClient

client = SearchClient.create('YourApplicationID', 'YourAdminAPIKey')
index = client.init_index('your_index_name')

Configure Index Settings#
Even if we want to sort by distance to a location we need the textual relevance to be good in case refine the search with a query.

For that lets configure the index.

index.set_settings(
  searchableAttributes: [
    'name',
    'city',
    'country',
    'iata_code'
  ],
  customRanking: [
    'desc(links_count)'
  ]
)

Searchable attributes#
We’re going to search in our 4 textual attributes: name, city, country and iata_code.......

 


 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.