Problem/Motivation
For the same reason as ticket #3454606: Add query object to QueryParamsEvent., I'd need to alter some boost to certain searches, based on data that has been added to the search_api query object by a query processor.
Proposed resolution
Pass the query to \Drupal\elasticsearch_connector\Event\QueryParamsEvent, so that listening event handlers have access to it.
Remaining tasks
Write initial patch— done for 8.0.x by @drdam in merge request !99 and for 9.0.x by @mparker17 in merge request !182Add tests— done by @drdam by #13Review and feedback— done by @mparker17 in #14RTBC and feedback— done by @mparker17 in #15Commit to 9.0.x— done by @mparker17 in #19Commit to 8.0.x— done by @mparker17 in #21Release 9.0.x- released in 9.0.0-alpha3 by @mparker17Release 8.0.x- released in 8.0.0-alpha7 by @mparker17
User interface changes
None.
API changes
When constructing a \Drupal\elasticsearch_connector\Event\QueryParamsEvent, you must now pass a \Drupal\search_api\Query\Query to the constructor.
Adds \Drupal\elasticsearch_connector\Event\QueryParamsEvent::getQuery() : \Drupal\search_api\Query\Query
Data model changes
None.
| Comment | File | Size | Author |
|---|
Issue fork elasticsearch_connector-3539863
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
drdam commentedFix patch
Comment #5
mparker17@drdam, thank you for the contribution!
I committed your code to a merge request (and updated the issue summary) to make it easier for me to review.
I changed the version to
8.0.x-devbecause this issue applies to the latest development version as well.I took a very quick look at your patch: it looks good to me (I anticipate some phpcs notices about documentation, but I expect that will be easy to fix).
Thanks for tagging this with "Needs tests"! Is there anything that I can do to help with writing tests for this change?
Comment #6
mparker17I notice that Testbot is detecting a failing test.
Fortunately, I think it should be pretty easy to resolve: the code that constructs a
new QueryParamsEventin\Drupal\Tests\elasticsearch_connector\Unit\SearchAPI\Query\QueryParamBuilderTest::testBuildQueryParams()will need to be updated to pass aQuery(or a test double for aQuery).Comment #7
mparker17(small update to issue summary)
Comment #8
mparker17Quick note, I ran phpcbf on the code, and it fixed the phpcs errors.
Comment #9
mparker17Also, we should add or update a change record to assist people upgrading from 8.x-7.x. Note we have a draft, not-complete-yet change record with some information on events that existed in the 8.x-7.x and their equivalents in 8.0.x (if applicable) — not sure if we need to update that, or create a new change record.
Comment #10
mparker17(sorry for the noise: I rebased onto the latest
8.0.x, so that the phpstan pipeline wouldn't warn us about a deprecation that was fixed in8.0.x)Comment #11
mparker17Briefly checking the status of this issue after releasing 8.0.0-alpha5...
Comment #12
drdam commentedThe error are on the test who send a queryParamsEvent, need the new query param.
I'm fighting with phpunit and prophesize ....
Comment #13
drdam commentedComment #14
mparker17@drdam apologies for the delay in reviewing. This looks good. I've made a small tweak to use QueryInterface consistently in QueryParamsEvent (i.e.: instead of a Query sometimes). If tests pass, I'll create a 9.0.x merge request, merge it, then merge your merge request. Thank you very much for the contribution, and your patience with me!
Comment #15
mparker17@drdam wrote a test and I've added https://www.drupal.org/node/3576752 as a change record, so those tags can be removed.
The tests also still pass after I rebased yesterday and changed Query -> QueryInterface in the event, and everything looks good to me, so I'm going to mark this as RTBC and proceed with merging to both 9.0.x and 8.0.x.
Comment #18
mparker17Updated the issue summary for record-keeping purposes
Comment #20
mparker17Merging to 8.0.x next.
Comment #22
mparker17Merged to 8.0.x. I will update this issue when this change is released. Thanks again for your patience!
Comment #25
mparker17The changes in this issue were released in elasticsearch_connector-9.0.0-alpha3, and elasticsearch_connector-8.0.0-alpha7