redmine_full_text_search icon indicating copy to clipboard operation
redmine_full_text_search copied to clipboard

hooks/issue_query_any_searchable: add multi field AND search

Open otegami opened this issue 9 months ago • 3 comments

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 avatar Mar 04 '25 04:03 otegami

🗒️ 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 avatar Mar 28 '25 08:03 otegami

It seems that some CI jobs are failing.

kou avatar Mar 31 '25 08:03 kou

It seems that some CI jobs are failing.

Thank you so much. fix: https://github.com/clear-code/redmine_full_text_search/pull/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.

otegami avatar Apr 01 '25 02:04 otegami