Search based on User Location

I would like to have advanced search to have a filter based on User Location, or Location of an event or a location wherever applicable. How can I configure this?

  • You could do the following to accomplish this and plan on working directly with Solr.

    1. Read up on how these types of searches work in Solr if you are not already familiar.
    2. Capture the user location, probably by having them set it via profile.
      1. Done with user profile APIs
    3. Store the location data of content within search
      1. Done by capturing this information at the time of posting and retrieving this stored data to store in search. You can use the BeforeSearchBulkIndexing event to get access to the document being indexed and add data to search index.
    4. Add geo data to the site searches when necessary
      1. Done by adjusting the raw search query using the BeforeSolrSearchEventHandler event. You will need this event because of the format of the geo queries. This and the indexing can also be done with an automation using the equivalent events (eg).
      2. Because you are adjusting all queries with the above look at using process state (also widget and automation equivalents) to "trigger" this logic only in places you want this to happen. i.e. set a flag when you want this to kick in and check for this flag before adjusting the raw query.

    I would recommend taking the shortest route first to start getting results and seeing results. The shortest path would be doing #3 with fake/per-determined data and #4.

    Note: You will also have to decide when and how you want to apply the geo search aspects. For example, you may want to boost (influence scoring but return all results) the results in some case and in other cases you may want to filter (exclude anything outside the results). I dont know the use case enough to recommend one way over the other.