2

Is it possible (and if so how?) to create dynamically calculated values as part of a SharePoint programmatic Search Query?

My predicament is I need to filter search results to only items that are within a proximity distance of a user-supplied postcode value (e.g. Schools within 5 miles of my house). I know it is possible to use Sort Formulas (http://msdn.microsoft.com/en-us/library/office/jj938031.aspx#code-snippet-6) to sort items based on these formulae but I also need to filter by them (i.e. all results within 5 miles) and also retrieve the distance as a value for each item in the result set.

If I was to compare this requirement to a SQL database query you can add dynamic columns to your result set, you can sort by them and you can filter by them. From what I've found in SharePoint 2013 search you are only able to sort on these dynamic values, not return them or filter by them. Does anyone know different?

My end goal is to create a custom refiner based on the Distance values (which has a separate question here: Using SharePoint 2013 Geolocation Field as a Search "Distance" Refiner).

1 Answer 1

1

I think this is not possible OOTB. You could get it to work with a custom refiner doing the calculation and showing the "less than 5km" something values.

6
  • Hi Max, thanks for your input. I've still not looked at custom refiners in great detail but I'm wondering what the actual refined query will look like. It's one thing to create the visuals of the refiner but when a user clicks on "Less than 5km" we need to convert that into a Search query - what would that look like? Dec 16, 2013 at 13:06
  • You need to do the math in the custom refiner - tbh I dont know how complicated it is, but it should be doable. Dec 17, 2013 at 7:00
  • "Should be". So we have access to each item's longitude and latitude number from the search index. We can use JavaScript client-side to work out the proximity distance for each item. We can then build a refiner's visuals based on those grouped proximities. The problem is it's not possible to query the search index on that proximity value - 1) because it doesn't exist in the search index and 2) because you can't generate dynamic managed properties on the fly. To me it seems like a feature only Microsoft can implement. i.e. enhance the built-in geolocation features and provide the refiner. Dec 17, 2013 at 13:18
  • Would love someone to prove me wrong by the way ;0) Dec 17, 2013 at 13:18
  • Sure "should" - my technical guts tell me that it is doable ;) Dec 17, 2013 at 22:42

Your Answer

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

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