Try our conversational search powered by Generative AI!

Filtering a list of geo locations

Vote:
 

Hi,

I have an object which contains a list of geographic locations as this:

public List Locations{get; set;}

This list is being correctly (as far as I can see) indexed by EPiServer Find.

I would then like to use the Within method for each of the locations in the Locations-list to check if any of them are within the specified polygon specified in the Within method.

I've tried using MatchContained, which not really is an option - and also tried using Nested2Find (changing the Location-list to NestedList using as follows:

query.Filter(x => x.Locations, l => l.Within((IEnumerable) bounds));

but this throws an exception saying:

QueryParsingException[[myIndex_Dev] failed to find geo_point field []


Any ideas on how to accomplish what I'm looking for ?

#109825
Oct 15, 2014 14:50
Vote:
 

Did you ever figure this out?  I have the same issue.

#133454
Sep 06, 2015 0:13
Vote:
 

Could you use the WithinDistanceFrom method? 

query.Filter(p => p.Locations.WithinDistanceFrom(x.Locations, kilometers.Kilometers()));
#133459
Sep 07, 2015 7:52
Vote:
 

When I attempt to index a list of GeoLocations, they do not get indexed in Find as a geolocation, they are missing the "$$geo" portion of the name.  So I see this in the json:

"TestLocations": [
        {
            "lat": 39.9608,
            "lon": -82.9912
        },
        {
            "lat": 39.9605,
            "lon": -82.9911
        }
    ],




instead of this:
"Location$$geo": {
                        "lat": 39.9605,
                        "lon": -82.9911
                    }



I can add another layer, so insead of creating a List<GeoLocation>, I create another class TestLocation that only contains a GeoLocation property, then generate a List<TestLocaton>. This gives me the following json:

"TestLocations": [
        {
            "Location$$geo": {
                "lat": 39.9593,
                "lon": -83.0226
            },
            "$type": "ProviderData.TestLocation, xxxx",
            "___types": [
                "ProviderData.TestLocation",
                "System.Object"
            ]
        },
        {
            "Location$$geo": {
                "lat": 40.1122,
                "lon": -82.947
            },
            "$type": "ProviderData.TestLocation, xxxx",
            "___types": [
                "ProviderData.TestLocation",
                "System.Object"
            ]
        }
    ],
I tried using Nested2Find, but get the following error:

The remote server returned an error: (400) Bad Request.
SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[IoCuZPkvTjaUn5al-iMxgQ][xxxxx][0]: RemoteTransportException[[use1dfindprod01esd02][inet[/10.53.4.6:9300]][search/phase/query]]; nested: SearchParseException

Without using Nested2Find, I'm not sure how to access the nested data.


#133504
Sep 07, 2015 23:43
Vote:
 

Have you found solution?

#150693
Jun 27, 2016 19:29
Vote:
 

I am also trying to achieve something similar. Did anyone get this to work?

#170780
Oct 30, 2016 17:12
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.