Hi. I'm trying to power a job board and allow user...
# community-help
n
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?
j
I'm no expert but I THINK you're looking for this: https://typesense.org/docs/0.21.0/api/documents.html#geosearch
n
Thanks James. Exactly that. But can I combine multiple locations, so query all records in one location OR another location?
j
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
I think it would be
{filter_by: ['location-1', 'location-2']}
in your search query (replacing locations with your actual like... locations
n
Thanks! I'll give it a try.
j
filter_by: locations:=['location-1', 'location-2']
I think. Assuming locations is the field you use to store that data.
that might be a more accurate, working way (again, I'm not expert, just learning myself)
They talk a little about filter_by syntax here in a previous message https://typesense-community.slack.com/archives/C01P749MET0/p1626083075105300
j
@Nicholas Stephan 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?
n
@Jason Bosco The locations would be tagged with lat/lng.
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.
j
@Nicholas Stephan 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.
n
@Jason Bosco Thanks. Do the individual hits come back with some kind of relevance score that I can use to sort the aggregated results?
j
Yup, the
_text_match
score in each hit can be used to aggregate across requests
n
Perfect. Thanks.
👍 1