-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Feature request: Order Location searches using near
in closest distance to center of the box
#4650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Something like (if we go the circle way):
or if continuing with the box search:
|
If the database underneath has native support that will be far better. |
Quick search show that postgres, ms and h2 all support cosine functions |
@brianpos do you mean that its a problem to let the database do Cosine operations? |
This is a neat idea. I think personally I'd prefer for it to only sort this way if a |
Just adding to this, @jkiddo do you have an opinion on the circle vs box part? We did think about implementing the circle math back when we originally built the near support, but we ultimately picked the box model because we figured it was likely to perform much better in a cross-database way. We've never really had any feedback on that decision though. I know a bunch of people who use this feature, but it's not obvious that it's the optimal solution from a "how would I expect this to work" kind of perspective. |
It's safe to say that the box model way is probably the most cross-database friendly way to do it for sure (fun fact: the SQL is the same across PostgresQL and H2 AFAIK). Whether its a box or a circle is my least important aspect of the feature request. Most important to me is the sort part. @jamesagnew I totally agree that the proper way to do it is using a |
That PR looks amazing! While on this topic - there is also the http://hl7.org/fhir/R4/location.html#positional (R4) / https://www.hl7.org/fhir/location.html#8.7.6.1.1 (R5) extension mentioned on the search results:
I tried to shoehorn that into the results using an interceptor when querying but I quickly found that using that approach only worked for the first result page (as it was evaulated only on |
@jamesagnew did you have a look at my last comment? |
I did - but the change was already under review and I think adding the distance extension to search results would be a bigger change in order to do it right. Would probably need some work on the search result bundle generation infrastructure so I think it deserves its own ticket. |
@jamesagnew Makes perfect sense! Thank you so much for the improvement! (Would you like me to create a new ticket for that?) |
Currently, the searches on Location using
near
are not returned in the order closest to the center. It would be awesome if that could be done - either using the _sort parameter or just default to that order (aka. Manhatten distance).The text was updated successfully, but these errors were encountered: