Skip to content

Improve afterSearch event in search service #11882

Closed Answered by brandonkelly
gglnx asked this question in Ideas
Discussion options

You must be logged in to vote

Just made the following changes for Craft 4.3: (d26f4ae)

  • craft\events\SearchEvent now has a $scores property.
  • craft\services\Search::searchElements() will now trigger a beforeScoreResults event (EVENT_BEFORE_SCORE_RESULTS), and will respect any changes made to SearchEvent::$results. Event handlers can also set SearchEvent::$scores from there, which will override Craft’s internal score calculations.
  • The afterSearch event (EVENT_AFTER_SEARCH) now passes the result scores to SearchEvent::$scores, and any changes made to it will be returned by searchEvent().

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@gglnx
Comment options

@brandonkelly
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
extensibility 🔌 features related to plugin/module dev
2 participants