Skip to content

Conversation

edivalentinitu
Copy link
Contributor

❤️ Thank you for your contribution!

Description

Please describe briefly your pull request.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@edivalentinitu
Copy link
Contributor Author

edivalentinitu commented Apr 29, 2025

Original issue: custom requests from https://github.com/tu-graz-library/invenio-curations are now shown when searching for a user's requests.

Cause: apparently this line. But I could not replicate the problem in the standard invenio implementation.

Reasons: Following these lines: https://github.com/inveniosoftware/invenio-records-resources/blob/a9389e4cb179d6ab515282d37b60983bef8c06b0/invenio_records_resources/services/records/service.py#L140 this extra filter prevents requests that come with default_filter = MatchAll() queries from being shown. In the standard invenio implementation, this is hidden by Status wrapper in the PermissionPolicy, for example: can_read = [Status(["created"], [Creator()])], which generates a default filter query that is not affected by this extra filter.
Second reason is that must query does not need minimum_should_match parameter.

Debug:
default_filter before: MatchAll()
extra filter: Bool(minimum_should_match=1, must=[Bool(must_not=[Term(status='created')])])
default filter after: Bool(minimum_should_match=1, must=[Bool(must_not=[Term(status='created')])])

@edivalentinitu edivalentinitu marked this pull request as ready for review April 29, 2025 07:44
@edivalentinitu edivalentinitu requested a review from zzacharo April 29, 2025 07:44
@@ -292,7 +292,6 @@ def search_user_requests(
extra_filter=dsl.Q(
"bool",
must=[~dsl.Q("term", **{"status": "created"})],
minimum_should_match=1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @edivalentinitu , thanks for the commit! I understand that the minimum_should_match=1 is redundant with the must operation but I think don't understand how it solved the problem you described.... Could you please elaborate a bit more on what is the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because our usecase does not generate search filters based on permissions, the only filter left was this extra filter and the search is somehow not evaluated correctly. There are no created requests, yet still the search returns no values. I am no opensearch expert and at first I just observed that if I remove this redundant param, the search for our usecase works ok, but I am open to suggestions if there could be another way of dealing with this.

Copy link
Member

@zzacharo zzacharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slint do you see maybe any hidden potential problem?

@slint
Copy link
Member

slint commented Apr 30, 2025

@slint do you see maybe any hidden potential problem?

Just from reading https://docs.opensearch.org/docs/latest/query-dsl/minimum-should-match/#default-minimum_should_match-value, since it doesn't document what happens when you pass minimum_should_match without any should clauses, I agree with removing the parameter, or else it's basically either a "no-op", "undefined behaviour", or an error.

@zzacharo zzacharo merged commit 38e7392 into inveniosoftware:master Apr 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants