-
Notifications
You must be signed in to change notification settings - Fork 864
SOLR-13706: Config API output for the "highlight" searchComponent is no longer dropped #5015
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
nick-boss-tech
wants to merge
10
commits into
apache:main
Choose a base branch
from
nick-boss-tech:solr-13706-submit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2f2298c
SOLR-13706: Group PluginInfo children by type in Config API output
nick-boss-tech f513244
SOLR-13706: add testing handoff
nick-boss-tech ab3f569
SOLR-13706: add children-grouped-by-type serialization test
nick-boss-tech 7a44df0
SOLR-13706: remove TESTING.md handoff file
nick-boss-tech 289d13b
SOLR-13706: add end-to-end Config API highlight test, unnamed-child t…
nick-boss-tech d38c762
SOLR-13706: apply gradle tidy formatting to TestConfigHighlightOutput…
nick-boss-tech 25fad2f
SOLR-13706: convert TestConfigHighlightOutput from SolrTestCaseJ4 to …
nick-boss-tech b062f3b
SOLR-13706: changelog type changed with an upgrade note for the Confi…
nick-boss-tech 51075ab
SOLR-13706: simplify the child grouping in PluginInfo.writeMap
nick-boss-tech c96d7ee
SOLR-13706: build the config directly in TestConfigHighlightOutput
nick-boss-tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| title: The Config API now returns the highlight searchComponent, with child plugins keyed by their type instead of their name | ||
| type: changed | ||
| authors: | ||
| - name: Nick Shanin | ||
| links: | ||
| - name: SOLR-13706 | ||
| url: https://issues.apache.org/jira/browse/SOLR-13706 |
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
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
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
61 changes: 61 additions & 0 deletions
61
solr/core/src/test/org/apache/solr/core/TestConfigHighlightOutput.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.solr.core; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import org.apache.solr.SolrTestCase; | ||
| import org.apache.solr.SolrTestCaseJ4; | ||
| import org.apache.solr.common.util.Utils; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
|
|
||
| /** Tests that the serialized config, as returned by the Config API, includes the highlighter. */ | ||
| public class TestConfigHighlightOutput extends SolrTestCase { | ||
|
|
||
| @BeforeClass | ||
| public static void beforeClass() { | ||
| // Sets the randomized solr.tests.* properties the collection1 solrconfig.xml requires. | ||
| SolrTestCaseJ4.newRandomConfig(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testHighlightComponentIsWrittenWithItsChildren() throws Exception { | ||
| SolrConfig solrConfig = | ||
| new SolrConfig(SolrTestCaseJ4.TEST_PATH().resolve("collection1"), "solrconfig.xml"); | ||
| Object config = Utils.fromJSONString(solrConfig.jsonStr()); | ||
| Object highlighting = | ||
| Utils.getObjectByPath( | ||
| config, false, List.of("searchComponent", "highlight", "highlighting")); | ||
| assertTrue("highlighting must be written as an object", highlighting instanceof Map); | ||
|
|
||
| // the child types are keys, even though several children share the name "simple" | ||
| for (String type : | ||
| List.of( | ||
| "fragmenter", "formatter", "fragListBuilder", "fragmentsBuilder", "boundaryScanner")) { | ||
| assertNotNull("missing child type " + type, ((Map<?, ?>) highlighting).get(type)); | ||
| } | ||
| assertFalse(((Map<?, ?>) highlighting).containsKey("simple")); | ||
|
|
||
| assertEquals(2, ((List<?>) ((Map<?, ?>) highlighting).get("fragmenter")).size()); | ||
| assertEquals(2, ((List<?>) ((Map<?, ?>) highlighting).get("fragmentsBuilder")).size()); | ||
| assertEquals(2, ((List<?>) ((Map<?, ?>) highlighting).get("boundaryScanner")).size()); | ||
| assertEquals("html", ((Map<?, ?>) ((Map<?, ?>) highlighting).get("formatter")).get("name")); | ||
| assertEquals( | ||
| "simple", ((Map<?, ?>) ((Map<?, ?>) highlighting).get("fragListBuilder")).get("name")); | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So…. I wonder if instead of fixing the v1 api, should this be done in v2?? That’s our future. We will be removing v1 APIs starting in Solr 11(???) and so is this fix in the v2 api???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 AI text below 🤖 (posted on behalf of Nick Shanin)
Good question; I checked. The v2 config API is not a separate implementation: GetConfigAPI (solr/core/src/java/org/apache/solr/handler/admin/api/GetConfigAPI.java:46) delegates every call to SolrConfigHandler, the same handler behind the v1 /config path, and SolrConfigHandler.getApis (solr/core/src/java/org/apache/solr/handler/SolrConfigHandler.java:1063) is what registers those v2 endpoints. Both surfaces build the response from SolrConfig (SolrConfigHandler.java:341) and serialize each plugin through PluginInfo.writeMap (solr/core/src/java/org/apache/solr/core/PluginInfo.java:197), which is the method this PR changes. So on the base code the highlight component was missing from the v2 output too, for the same reason, and this fix covers v2 as it stands. There is no v2-only config output path in the tree that would need its own version of the change.