Improve Search Experience
Improve Search Experience
By Ordering Results By Distance From a Given Reference Point
Users frequently wish to
look for products connected to a specific area. For instance, they may want to
locate the coffee shop closest to their location. AI Search has geospatial
features that you can use in queries to compare locations on the surface of the
Earth.
What are Geo-Spatial Functions?
The hotel's location is a
crucial factor to take into account when making a reservation. For instance,
you will want a hotel close to the Eiffel Tower if you're planning a trip to
view it. To ask AI Search to return results based on their location
information, you can use two functions in your query:
geo.distance -
This function returns the distance in a straight line across the Earth's
surface from the point you specify to the location of the search result.
geo.intersects -
This function returns true if the location of a search result is inside a
polygon that you specify.
Make sure the location
for results is included in your index before using these functions. Latitude
and longitude should be stored in location fields of the datatype
Edm.GeographyPoint.
Use geo.distance Function
The function geo.distance
returns the distance in kilometers between two points given as inputs. Let's
say you're trying to choose a hotel close to the Eiffel Tower. The query above
can be changed by adding a new filter. The query returns all the luxury hotels
in the index within five kilometers of the Eiffel Tower.
Use geo.intersects Function
Let's say you have made
up your mind to visit the Eiffel Tower in Paris's seventh district. You want to
be as specific as you can while looking for a hotel. The geo.intersects
function can be used to create such a query.
The geo.intersects
function uses three or more points to compare a position with a polygon on the
surface of the Earth. You can make a form that closely resembles an area, like
an arrondissement, by utilizing a polygon. geo.intersects returns a boolean
value, so it's not possible to use it in an orderby clause.
Conclusion
We have successfully
learnt about improving search experience.
Comments
Post a Comment