#community-help

Using TypeSense for Geolocation Tagged Job Search

TLDR Nicholas needed help to enable geo-location based job search on a board. James suggested using filter_by from TypeSense, while Jason elaborated on 'OR' and 'AND' operations in TypeSense.

Powered by Struct AI

1

16
27mo
Solved
Join the chat
Oct 19, 2021 (27 months ago)
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
08:59 PM
Hi. I'm trying to power a job board and allow users to search jobs that are in one of multiple geo-locations or flagged as remote. Is that possible with TypeSense?
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
09:01 PM
I'm no expert but I THINK you're looking for this: https://typesense.org/docs/0.21.0/api/documents.html#geosearch
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
09:07 PM
Thanks James. Exactly that. But can I combine multiple locations, so query all records in one location OR another location?
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
09:15 PM
In that case I believe your search query would just need a filter_by statement. There is a decent example here: https://typesense.org/docs/0.21.0/api/documents.html#arguments
09:17
James
09:17 PM
I think it would be {filter_by: ['location-1', 'location-2']} in your search query (replacing locations with your actual like... locations
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
09:17 PM
Thanks! I'll give it a try.
James
Photo of md5-ae7223c767d7228418baf97773be94d6
James
09:18 PM
filter_by: locations:=['location-1', 'location-2'] I think. Assuming locations is the field you use to store that data.
09:19
James
09:19 PM
that might be a more accurate, working way (again, I'm not expert, just learning myself)
09:20
James
09:20 PM
They talk a little about filter_by syntax here in a previous message

https://typesense-community.slack.com/archives/C01P749MET0/p1626083075105300
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:31 PM
Nicholas When you say geo-locations, are these tagged with lat / lng or do they contain for eg: city and country names in your use case?
Oct 21, 2021 (27 months ago)
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
12:11 AM
Jason The locations would be tagged with lat/lng.
12:13
Nicholas
12:13 AM
The full query I'm going for might include a full-text search, be filtered to one or more types ("full time", "part time", "contract", etc) , one or more fields ("design", "engineering", etc), and one or more lat/lng geo-locations.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:28 AM
Nicholas Got it. Typesense currently only supports doing ORing values in the same field, and ANDing values across fields or same field. If you need to OR across fields, the work-around would be to send multiple queries using the multi_search endpoint, with each query having a particular field and then aggregating the results on the client side for these queries.
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
01:03 AM
Jason Thanks. Do the individual hits come back with some kind of relevance score that I can use to sort the aggregated results?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:04 AM
Yup, the _text_match score in each hit can be used to aggregate across requests
Nicholas
Photo of md5-8e5dc570a4fa7ff80428aba11c0b6968
Nicholas
01:04 AM
Perfect. Thanks.

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Multiple Filters and JSON Requests in Typesense

Manish asked about multiple filter_by arguments, JSON input, and using multisearch. Jason offered typesense documentation links, examples, and how to use JSON formatted requests with multisearch. Ed shared a similar use case.

6

44
5mo
Solved

Faceting and Filtering Issue in Typesense

Hauke faced issues with facets filtering in Typesense. Kishore Nallan recommended using the instantsearch.js JS library or the multi_search endpoint for independent search queries.

12
3mo
Solved

Troubleshooting Typesense API Analytics Query Suggestions

Md was confused about implementing Typesense's Analytics Query Suggestions and experienced issues with collections returning no hits. Assistance from Kishore Nallan eventually led to the identification that analytics had to be enabled. They also discussed tracking duplicate and empty queries, resulting in Md creating a Github issue.

3

27
3mo
Solved

Moving from Algolia to Typesense: Questions and Answers

Juan sought advice from Kishore Nallan about moving from Algolia to Typesense, handling MultiSearch, setting parameters, checking imported documents, and a specific syntax query.

1

22
22mo
Solved

Understanding and Implementing Typesense Dart Library with Flutter

Alexandro sought help with the Typesense Dart library. Jason explained that the library is in progress, discussed utilizing other HTTP libraries, and provided detailed instructions on utilizing Typesense with Flutter. Alexandro provided feedback on the Typesense UI and expressed interest in creating a tutorial video.

10

82
32mo