I am working on an app where the goal is to find likeminded people in your area, nothing revolutionary.
Given a user's age, minAge,maxAge fields, we want to query for other docs that meet the criteria. However, the search criteria need to be met on both sides. For example, the user's age should be in the minAge and maxAge range of the "incoming" docs.
What is the most efficient way of doing this? I currently have a solution using function_score but not sure if it's the most efficient:
Please be patient in waiting for responses to your question and refrain from pinging multiple times asking for a response or opening multiple topics for the same question. This is a community forum, it may take time for someone to reply to your question. For more information please refer to the Community Code of Conduct specifically the section "Be patient". Also, please refrain from pinging folks directly, this is a forum and anyone that participates might be able to assist you.
If you are in need of a service with an SLA that covers response times for questions then you may want to consider talking to us about a subscription.
It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.
the above works but my concern is around efficiency, would you say this is the most efficient way of filtering based on the incoming parameters? is there any other feature that I am not aware of / should look into? thank you so much for your help!
Maybe I'm missing something, but I thought @dadoonet 's original selection was to replace the script with a regular Boolean query with filters and range queries.
I'll confess that I don't have a lot of expert knowledge in our geospacial search, perhaps you could index a geocircle with the allowed radius? You'd have to play with the search to see if it worked for your needs.
I did look at the geo-distance query, and it's what I used to find the docs that are within the search radius of the user that's running the query. But I couldn't find a way to do the inverse of it where we make sure that the distance from the doc is within the search radius of the other user...does that make sense? thank you!
I have no idea of what "the other user" means in this context.
Anyway, if you want to move forward, please provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.
A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.
where we have a pre-computed locationGrids field, that has the geo-hex values of a user's location + search radius. so it sets locationGrids to all the geo-hex values of the hexagons that are within the search radius for the user.
and so when we search, we just do a terms_set match on that field, and this also seems to work pretty well.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.