Skip to content

hooks/issue_query_any_searchable: add multi field AND search #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

otegami
Copy link
Member

@otegami otegami commented Mar 4, 2025

GitHub: GH-163

Problem

The existing "Any searchable text" issue filter cannot perform AND searches across multiple fields.

Cause

The existing implementation of IssueQuery#sql_for_any_searchable_field did not handle AND searches for multiple fields. The AND search query construction was limited to single-field searches, and there was no mechanism to build filter conditions that combine criteria across multiple fields.

Solution

This change introduces the FullTextSearch::Hooks::IssueQueryAnySearchable module, which extends IssueQuery#sql_for_any_searchable_field to perform AND searches across multiple fields.

Additional Information

Mroonga Support

Currently, the implementation only supports PGroonga.
Mroonga-based systems are not supported yet and will support in the following PR.

OR Search Considerations

If you need OR search functionality, please note that selecting the contains_any_of filter does not perform an OR search. Instead, you must specify the query in Groonga Query style (e.g., using keyword OR keyword) to achieve an OR search.

@otegami otegami force-pushed the multi-field-and-search branch 2 times, most recently from aada908 to cecdd44 Compare March 4, 2025 08:20
@otegami otegami force-pushed the multi-field-and-search branch 2 times, most recently from 7eded90 to 1f23e75 Compare March 5, 2025 08:36
def sql_for_any_searchable_field(field, operator, value)
# TODO: Implement AND searches across multiple fields.
super(field, operator, value)
## TODO List
# - filter by match leves('~', '*~')
Copy link
Member Author

Choose a reason for hiding this comment

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

If we try to deal with *~, I think we will have to parse the query but we don't want to do that. So we should think of the other way like announcing it to user using Groonga query.

@otegami otegami force-pushed the multi-field-and-search branch 2 times, most recently from 07490b3 to 816c2a2 Compare March 28, 2025 07:41
@otegami otegami force-pushed the multi-field-and-search branch 2 times, most recently from c6e957b to 2e7a4a0 Compare March 28, 2025 08:25
@otegami
Copy link
Member Author

otegami commented Mar 28, 2025

🗒️
fix: eeb7f4d In default, Groonga will return only 10 records but it didn't return the expected record ids when the search result was over the limit.
Tests are still flaky now.
In my local, these tests passed even if I specified the same seed value.
I think It might be the environment problem. I will figure it out.

@otegami otegami force-pushed the multi-field-and-search branch from 2e7a4a0 to eeb7f4d Compare March 31, 2025 04:02
@otegami otegami changed the title WIP: add multi field AND search hooks/issue_query_any_searchable: add multi field AND search Mar 31, 2025
@otegami otegami marked this pull request as ready for review March 31, 2025 04:24
@kou
Copy link
Member

kou commented Mar 31, 2025

It seems that some CI jobs are failing.

@otegami
Copy link
Member Author

otegami commented Apr 1, 2025

It seems that some CI jobs are failing.

Thank you so much.
fix: #168 I will fix the following test about Redmine 5.0 & PostgreSQL & Ruby 3.0 in another PR.
The other test fails aren't related to this changes. And also I have already sent the patch to upstream at https://www.redmine.org/issues/42422.

Run cd ../redmine
 set_config 
------------
 
(1 row)

Webdrivers < 5.3.0 doesn't work. See also: https://github.com/titusfortner/webdrivers/pull/251
Webdrivers::VersionError: Unable to find latest point release version for 134.0.6998. You appear to be using a non-production version of Chrome. Please set `Webdrivers::Chromedriver.required_version = <desired driver version>` to a known chromedriver version: https://chromedriver.storage.googleapis.com/index.html
Run options: --seed 47824

# Running:

E

Error:
FullTextSearch::SimilarSearchIssueTest#test_same_structure_on_issue:
ActiveRecord::RecordInvalid: Validation failed: Tracker cannot be blank, Priority cannot be blank, Status cannot be blank
    test/object_helpers.rb:107:in `generate!'
    plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:20:in `block in test_same_structure_on_issue'
    plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:19:in `test_same_structure_on_issue'

rails test plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:17

E

Error:
FullTextSearch::SimilarSearchIssueTest#test_same_structure_with_attachment:
RuntimeError: Neutered Exception ActiveRecord::RecordInvalid: Validation failed: Tracker cannot be blank, Priority cannot be blank, Status cannot be blank
    test/object_helpers.rb:107:in `generate!'
    plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:76:in `test_same_structure_with_attachment'

rails test plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:73

E

Error:
FullTextSearch::SimilarSearchIssueTest#test_same_structure_with_journal:
ActiveRecord::RecordInvalid: Validation failed: Tracker cannot be blank, Priority cannot be blank, Status cannot be blank
    test/object_helpers.rb:107:in `generate!'
    plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:51:in `block in test_same_structure_with_journal'
    plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:50:in `test_same_structure_with_journal'

rails test plugins/full_text_search/test/unit/full_text_search/similar_search_issue_test.rb:48

.......................SSSSSSSSS............................................................................

Finished in 75.868947s, 1.4630 runs/s, 1.6080 assertions/s.
111 runs, 122 assertions, 0 failures, 3 errors, 9 skips

You have skipped tests. Run with --verbose for details.

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.

2 participants