Fix: Respect search.searchForSolutionId config with Elasticsearch/OpenSearch - #3724
Merged
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
…nSearch Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
thorsten
marked this pull request as ready for review
November 2, 2025 09:50
Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with searching FAQ by ID when relevance support is enabled
Fix: Respect search.searchForSolutionId config with Elasticsearch/OpenSearch
Nov 2, 2025
thorsten
approved these changes
Nov 2, 2025
Owner
|
@copilot the tests are failing |
Co-authored-by: thorsten <45284+thorsten@users.noreply.github.com>
Contributor
Author
Fixed in commit 64e6e39. The issue was that Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Support search.searchForSolutionId configuration with Elasticsearch/OpenSearch ✅
Problem Statement
When Elasticsearch or OpenSearch (Relevance Support) is enabled, numeric searches don't respect the
search.searchForSolutionIdconfiguration. Users reported that searching by FAQ ID (e.g., "1001") works when relevance support is disabled, but fails when it's enabled.Root Cause
The
Search::search()method checks if the search term is numeric and immediately routes it tosearchDatabase(), bypassing the configured search engine (Elasticsearch/OpenSearch), regardless of thesearch.searchForSolutionIdconfiguration setting.Solution ✅
Modified
Search::search()to check BOTH conditions before routing to database search:search.searchForSolutionIdconfiguration is enabledMinimal Code Change (1 line):
Changes Made ✅
Search::search()method to respect configuration (1 line changed)Test Fix ✅
The tests were failing because
Configuration::set()only updates the database but not the in-memory config cache. Fixed by:ReflectionClassimportsetConfigValue()that uses reflection to directly set config values in memoryBehavior Matrix
Test Coverage ✅
Added 4 comprehensive test cases:
testSearchWithNumericTermWhenSolutionIdSearchEnabled- Numeric + config enabledtestSearchWithNumericTermWhenSolutionIdSearchDisabled- Numeric + config disabled + no enginestestSearchWithNumericTermWhenElasticsearchEnabledAndSolutionIdSearchDisabled- Numeric + ElasticsearchtestSearchWithNumericTermWhenOpenSearchEnabledAndSolutionIdSearchDisabled- Numeric + OpenSearchBackward Compatibility ✅
✓ Default value of
search.searchForSolutionIdis 'true'✓ Existing behavior preserved for all current installations
✓ New behavior only applies when admin explicitly disables solution ID search
Files Modified
phpmyfaq/src/phpMyFAQ/Search.php- 1 line changedtests/phpMyFAQ/SearchTest.php- Added reflection helper and 4 test casesTotal: 2 files changed, 88 insertions(+), 11 deletions(-)
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.