What query rule will boost "upcoming event" entities?

Hello!

I’d like to boost future events if the user searches “upcoming”, but I’m not sure exactly how to do it. I tried using a saved filter for “events” with a future start date, but it filtered out all the other results. I’d love to have the relevant upcoming events at the top of the universal results, and then the related FAQs etc. to come below. Is that possible?

Thanks!

I found this module that has exactly the example I’m looking for but I wasn’t able to get the provided code to work - I might be missing something?

Hello @Hannah_Mussi - in that module, which searchable field type were you planning on using? If you are using the in-platform config UI, you shouldn’t have to use any code to enable searchable fields.

I think your best bet would be to use a keywords field and enable it as textSearch or phraseMatch. You can input “upcoming” as a keyword for relevant entities and use query rules to fine-tune the entities and verticals order.

Thanks @Sam_Torres! Would I be able to apply the keyword dynamically as the date changes? Since “upcoming” only applies to event entities with a date in the future, I wouldn’t know how to add it only to those entities - does that makes sense?

Hey @Hannah_Mussi - yes, that makes total sense! For this use-case, I would recommend adding a saved filter for your Events vertical. You can specify the event date range to “is in the future” such that past events will automatically filter out of your experience & config:

Let me know if this helps.

Best,
Sam

Great! I have the saved filter.
@Sam_Torres - since i still want past events to appear (but “upcoming” be boosted to the top), is this possible through BOOST_ENTITIES query rule?

Hi @Hannah_Mussi! Thanks for the additional context on that.

I was able to find a solution for your use case here using Query Rules! The below will add an Events vertical filter to queries containing “upcoming” or “upcoming events”:

{
  "criteria": {
    "searchTermExactlyMatches": [
      "upcoming events",
      "upcoming"
    ]
  },
  "actions": [
    {
      "actionType": "ADD_FILTER",
      "filter": {
        "savedFilterId": {
          "$eq": "123456789"
        }
      },
      "verticals": [
        "events"
      ]
    }
  ]
}

If the query is simply “events”, then all your events (future and past) will return in results.

Best,
Sam

1 Like