Skip to content
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

Distance sort uses the wrong json structure. #150

Open
berkes opened this issue Jun 2, 2020 · 0 comments
Open

Distance sort uses the wrong json structure. #150

berkes opened this issue Jun 2, 2020 · 0 comments

Comments

@berkes
Copy link

berkes commented Jun 2, 2020

When crafting a distance sort, we get a wrong JSON structure:

   use rs_es::units as rs_u;
   use rs_es::operations::search::{Order, GeoDistance};

   GeoDistance::new("coord")
       .with_location(rs_u::Location::LatLon(coord.y, coord.x))
       .with_order(Order::Desc)
       .with_unit(rs_u::DistanceUnit::Meter)
       .build();

This gives us a:

    {
        "field": "coord",
        "location": {
            "lat": 51.84222,
            "lon": 5.85938
        },
        "order": "desc",
        "unit": "m"
    }

But it should be:

    {
        "_geo_distance": {
            "coord": {
                "lat": 51.84222,
                "lon": 5.85938
            },
            "order": "desc",
            "unit": "m"
        }
    }
berkes added a commit to berkes/rs-es that referenced this issue Jun 6, 2020
This fixes issue benashford#150, where the JSON is wrong for distance sorting.
The structure is a little non-standard, as it is wrapped in an object
with hardcoded _geo_distance as name.

Reaching through inner-outer and tupled structs is unfortunate, but
seems to be nessecary in order to keep the API the same and to
keep everything nicely contained inside a GeoDistance struct as seen
from the consumer or user.
berkes added a commit to berkes/rs-es that referenced this issue Jun 6, 2020
This fixes issue benashford#150, where the JSON is wrong for distance sorting.
The structure is a little non-standard, as it is wrapped in an object
with hardcoded _geo_distance as name.

Reaching through inner-outer and tupled structs is unfortunate, but
seems to be nessecary in order to keep the API the same and to
keep everything nicely contained inside a GeoDistance struct as seen
from the consumer or user.
berkes added a commit to berkes/rs-es that referenced this issue Jun 6, 2020
This fixes issue benashford#150, where the JSON is wrong for distance sorting.
The structure is a little non-standard, as it is wrapped in an object
with hardcoded _geo_distance as name.

Reaching through inner-outer and tupled structs is unfortunate, but
seems to be nessecary in order to keep the API the same and to
keep everything nicely contained inside a GeoDistance struct as seen
from the consumer or user.
berkes added a commit to berkes/rs-es that referenced this issue Jun 6, 2020
This fixes issue benashford#150, where the JSON is wrong for distance sorting.
The structure is a little non-standard, as it is wrapped in an object
with hardcoded _geo_distance as name.

Reaching through inner-outer and tupled structs is unfortunate, but
seems to be nessecary in order to keep the API the same and to
keep everything nicely contained inside a GeoDistance struct as seen
from the consumer or user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant