3

I have defined a Sitecore index field as below

[IndexField("_coordinates")]
public List<Coordinate> DealLocations { get; set; }

When I execute a query like

queryable.OrderByDistance(s => s.DealLocations, new Coordinate(latitude, longitude))

I got an exception in SOLR log as below

ERROR Solr Error : [The field _coordinates_sm does not support spatial filtering] - Query attempted: [({!geofilt pt=25.1406,55.1917 sfield=_coordinates_sm d=0 score=distance filter=false} AND _template:(f250acc7e16e4f6cb7b8a2e6f41a6bf4))]

It's working fine with a single Coordinate but when I define the field List<Coordinate>, I am getting an exception.

Is there any way, we can compare more than one Coordinates or list of Coordinates in SOLR query?

6
  • Is your goal is to sort DealLocations list values based on some coordinates? I think the error is valid because field _coordinates_sm in this case is not a Coordinate type but it is a list of Coordinate type which does not support spatial filtering. Mar 6, 2020 at 18:02
  • Is there any way to achieve this? Mar 7, 2020 at 2:21
  • How you are storing multiple coordinates for an item in Sitecore? are these coordinates stored as child items or stored as a field using treelist of multi list? Mar 7, 2020 at 13:53
  • It is stored as multilist field for an item. Mar 8, 2020 at 3:09
  • The solution i can suggest is to break each coordinate in its own index document so that you can run your spatial search against it. To achieve that either add coordinates as child items (instead of multi list), this way you can utilize indexing functionality/customisation already exists, other way can be to write your own crawler which will take care of creating multiple index document for that multlist field (i have not tried second approach but i think it is possible.) Mar 9, 2020 at 6:19

1 Answer 1

1

As discussed above in comments, you goal here is to filter an indexed document based on some coordinate from a list of coordinates, to achieve that you should break each coordinate in its own index document so that you can run your spatial search against it. I would suggest to either add coordinates as child items (instead of multi list), this way you can utilize indexing functionality/customisation already exists, other way will be to write your own crawler which will take care of creating multiple index document for that multlist field (i have not tried second approach but i think it is possible).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.