Hi, I have a use case for which I have to filter out all the documents whose coordinates lie in each other's range. I know how to filter out results based on one doc's location and search radius but I can't figure out how to do this for both sides
Now, I have to run a filter query with one person's coordinates and only those docs should be shown to me which lie in each other's range. How can I do that?
If I'm reading this right, you are saying you'd want to filter out any docs within 20km of Rahul, and then any remaining docs within 5km of Shikher, and so on. If so, I cannot think of a single query that would solve this. Off the top of my head, I would just:
Generate a sorted set of IDs by decreasing range, maybe using scan if you have a lot of documents. 2. For each document in the set, starting with the one with the largest range, find the set of documents that are within range and remove those documents from the set.
I'm just guessing here that filtering by larger ranges first will eliminate more documents earlier, thus reducing the number of documents you have consider as you iterate through the set. That is, the set will get smaller as you iterate through it.
I might not have been clear on this. So, I'll walk you through it once again. I have n number of docs in my index. And I have coordinates and search radius of all of them,
Now, if some user makes a query then what I have to do is that I wanna find all the docs, which lie in this user's search radius and this user should lie in their search radius.
Since there could be millions of docs in the index and this(location and search radius) is a dynamic field so I don't think it would be possible to do this at the time of indexing.
And secondly, would it be scalable to go with the approach you mentioned in steps 1 and 2?
I was wondering if there is any filter which could directly give me the distance between 2 coordinates. That I could use in a range query afterwards. By doing this, I'll be able to do this in a single query only.
Performance would depend on how many candidate docs were in range of Doc X. It wouldn't scale well for lots of candidates, that's for sure.
I think this is similar to a question I also failed to answer a while back, which also seemed like a computational geometry problem that could not be solved with a single ES query. Sorry I could not be more helpful!
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.