- Issue created by @SomebodySysop
- π©πͺGermany mkalkbrenner π©πͺ
https://git.drupalcode.org/project/search_api_solr/-/blob/4.x/src/Event/... is the right starting point. But it only adds events that are not already part of the layer above or below.
High level:
https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Event/S...Low level:
https://github.com/solariumphp/solarium/blob/master/src/Core/Event/Event... - πΊπΈUnited States SomebodySysop
Thank you. It looks like this is what I could use to react to any event on any Solr index object. Correct?
/**
* The postExecute event is thrown just after all execution is done.
*
* The event listener receives a Query instance and a Result instance.
*
* @var string
*/
public const POST_EXECUTE = PostExecute::class;So,
use Drupal\search_api\Query\QueryInterface; use Drupal\search_api\Query\ResultSetInterface; use Drupal\search_api_solr\Event\PostExecute; class MyModule { /** * The postExecute event is thrown just after all execution is done. * * The event listener receives a Query instance and a Result instance. * * @var string */ public const POST_EXECUTE = PostExecute::class; /** * Event subscriber callback for the postExecute event. * * @param \Drupal\search_api\Query\QueryInterface $query * The query object. * @param \Drupal\search_api\Query\ResultSetInterface $result_set * The result set object. */ public function onPostExecute(QueryInterface $query, ResultSetInterface $result_set) { // My code here. } }
I look at the $query to find the function (update, create, delete, index) and the $result to get the item(s) affected.
On at least the right track here?
- Status changed to Fixed
about 1 year ago 9:04am 16 June 2023 - π©πͺGermany mkalkbrenner π©πͺ
It depends on your requirements. If you need informations about a Drupal entity, it might be better to leverage Search API's events.
But with these events of all three layers, you can track the entire action. Now it is up to you.
- πΊπΈUnited States SomebodySysop
No, I am only trying to track when a solr index object is affected: created, updated, indexed or deleted. Period.
Thanks for the info. I'll see what I can do.
- πΊπΈUnited States SomebodySysop
Actually, I was able to accomplish my goals using the entity hooks. I wanted to use event subscriber instead, but just couldn't figure out the correct events to use. At any rate, for what I wanted to do (sync Solr index with vector store), I didn't need to monitor Search API (or Search API Solr) events. As Search API Solr automatically updates the Solr index on CRUD events, I only needed to monitor the Drupal entities for changes.
Again, for anyone else who bumps up against something like this, here is how I handled it:
Automatically closed - issue fixed for 2 weeks with no activity.