You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "Seunghan-Jung (via GitHub)" <gi...@apache.org> on 2024/09/08 09:47:52 UTC
[PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Seunghan-Jung opened a new pull request, #2697:
URL: https://github.com/apache/solr/pull/2697
https://issues.apache.org/jira/browse/SOLR-XXXXX
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Solr:
* https://issues.apache.org/jira/projects/SOLR
For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA.
To create a Jira issue, you will need to create an account there first.
The title of the PR should reference the Jira issue number in the form:
* SOLR-####: <short description of problem or changes>
SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
Please provide a short description of the changes you're making with this pull request.
# Solution
Please provide a short description of the approach taken to implement your solution.
# Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
# Checklist
Please review the following and check all that apply:
- [ ] I have reviewed the guidelines for [How to Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my code conforms to the standards described there to the best of my ability.
- [ ] I have created a Jira issue and added the issue ID to my pull request title.
- [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
- [ ] I have developed this patch against the `main` branch.
- [ ] I have run `./gradlew check`.
- [ ] I have added tests for my changes.
- [ ] I have added documentation for the [Reference Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2425412127
Proposed CHANGES.txt for 9.8, New Feature:
> SOLR-17444: The UnifiedHighlighter now supports an hl.passageSort option to control passage ordering per document startOffset|endOffset|score. (Seunghan-Jung)
I plan to merge with that in a day or two.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2697:
URL: https://github.com/apache/solr/pull/2697#discussion_r1779363345
##########
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java:
##########
@@ -314,6 +343,24 @@ protected PassageFormatter getFormatter(String fieldName) {
return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder));
}
+ @Override
+ protected Comparator<Passage> getPassageSortComparator(String fieldName) {
+ PassageSort passageSort =
+ PassageSort.parse(
+ params.getFieldParam(fieldName, HighlightParams.PASSAGE_SORT, PassageSort.START_OFFSET.key));
+
+ switch (passageSort) {
+ case START_OFFSET:
+ return Comparator.comparingInt(Passage::getStartOffset);
+ case END_OFFSET:
+ return Comparator.comparingInt(Passage::getEndOffset);
+ case SCORE:
+ return Comparator.comparingDouble(Passage::getScore);
+ default:
+ throw new AssertionError();
Review Comment:
If a user supplies a bogus value, we should throw a SolrException with BAD_REQUEST as you can see elsewhere in this file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #2697:
URL: https://github.com/apache/solr/pull/2697#discussion_r1779120744
##########
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java:
##########
@@ -314,6 +343,24 @@ protected PassageFormatter getFormatter(String fieldName) {
return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder));
}
+ @Override
+ protected Comparator<Passage> getPassageSortComparator(String fieldName) {
+ PassageSort passageSort =
+ PassageSort.parse(
+ params.getFieldParam(fieldName, HighlightParams.PASSAGE_SORT, "startOffset"));
Review Comment:
could you instead reference the START_OFFSET.key instead of this constant string?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2380669818
> It's somewhat unfortunate to have no Solr level test... but not strictly necessary. You could probably add a query & assertion to a test method in TestUnifiedSolrHighlighter. Just showing the param has an effect for one of the non-default options.
I was writing test code and discovered a bug that required a fix on the Lucene side, which I have now resolved. Here is the relevant PR: https://github.com/apache/lucene/pull/13832.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-5534405424
With Claude I tidied up some things and added a test. If no further input to the contrary, I'll merge Monday. Will be released in 10.1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2667190696
This PR is now closed due to 60 days of inactivity after being marked as stale. Re-opening this PR is still possible, in which case it will be marked as active again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #2697: SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter
URL: https://github.com/apache/solr/pull/2697
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on code in PR #2697:
URL: https://github.com/apache/solr/pull/2697#discussion_r1779530690
##########
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java:
##########
@@ -314,6 +343,24 @@ protected PassageFormatter getFormatter(String fieldName) {
return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder));
}
+ @Override
+ protected Comparator<Passage> getPassageSortComparator(String fieldName) {
+ PassageSort passageSort =
+ PassageSort.parse(
+ params.getFieldParam(fieldName, HighlightParams.PASSAGE_SORT, PassageSort.START_OFFSET.key));
+
+ switch (passageSort) {
+ case START_OFFSET:
+ return Comparator.comparingInt(Passage::getStartOffset);
+ case END_OFFSET:
+ return Comparator.comparingInt(Passage::getEndOffset);
+ case SCORE:
+ return Comparator.comparingDouble(Passage::getScore);
+ default:
+ throw new AssertionError();
Review Comment:
It was fixed in this commit: https://github.com/apache/solr/pull/2697/commits/deafe902701bf33013a5c694fc1e85e9c7530818.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #2697: SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter
URL: https://github.com/apache/solr/pull/2697
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley merged PR #2697:
URL: https://github.com/apache/solr/pull/2697
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2380643974
Just a thought -- is this enum actually buying us anything at all? It's a bunch of lines of code but only ultimately used for a set lookup and nothing else? If so, lets just have less lines of code and do away with it. switch-case on String literals and null if no arg provided.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on code in PR #2697:
URL: https://github.com/apache/solr/pull/2697#discussion_r1779548037
##########
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java:
##########
@@ -314,6 +343,26 @@ protected PassageFormatter getFormatter(String fieldName) {
return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder));
}
+ @Override
+ protected Comparator<Passage> getPassageSortComparator(String fieldName) {
+ String value = params.get(HighlightParams.PASSAGE_SORT, PassageSort.START_OFFSET.key);
+
+ PassageSort passageSort = PassageSort.parse(value);
+
+ switch (passageSort) {
+ case START_OFFSET:
+ return Comparator.comparingInt(Passage::getStartOffset);
Review Comment:
```suggestion
switch (passageSort) {
case "startOffset:
return Comparator.comparingInt(Passage::getStartOffset);
```
Is this the direction you were aiming for? Are you suggesting that we avoid creating unnecessary enum class and use string literals instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on code in PR #2697:
URL: https://github.com/apache/solr/pull/2697#discussion_r1779351977
##########
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java:
##########
@@ -314,6 +343,24 @@ protected PassageFormatter getFormatter(String fieldName) {
return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder));
}
+ @Override
+ protected Comparator<Passage> getPassageSortComparator(String fieldName) {
+ PassageSort passageSort =
+ PassageSort.parse(
+ params.getFieldParam(fieldName, HighlightParams.PASSAGE_SORT, "startOffset"));
Review Comment:
Thank you for the review. The feedback you provided has been addressed in commit 210a5ec.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2994546146
This PR is now closed due to 60 days of inactivity after being marked as stale. Re-opening this PR is still possible, in which case it will be marked as active again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2822742250
This PR has had no activity for 60 days and is now labeled as stale. Any new activity will remove the stale label. To attract more reviewers, please tag people who might be familiar with the code area and/or notify the dev@solr.apache.org mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2380663931
@dsmiley
> Just a thought -- is this enum actually buying us anything at all? It's a bunch of lines of code but only ultimately used for a set lookup and nothing else? If so, lets just have less lines of code and do away with it. switch-case on String literals and null if no arg provided.
The model I followed is the HighlightComponent.getHighlighter method.
https://github.com/apache/solr/blob/34f77886104a15f9e478cf7b4a5f6b0691d79eb7/solr/core/src/java/org/apache/solr/handler/component/HighlightComponent.java#L174-L194
I adopted this approach. This is also why I trigger an AssertionError in the default case of the switch statement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "Seunghan-Jung (via GitHub)" <gi...@apache.org>.
Seunghan-Jung commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2426218449
@dsmiley
I believe the PR I worked on to fix a bug (https://github.com/apache/lucene/pull/13832) is for Lucene version 10. I thought it would be merged before Solr version 10.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] SOLR-17444: Add Passage Sorting Option in UnifiedSolrHighlighter [solr]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2697:
URL: https://github.com/apache/solr/pull/2697#issuecomment-2557896086
This PR has had no activity for 60 days and is now labeled as stale. Any new activity will remove the stale label. To attract more reviewers, please tag people who might be familiar with the code area and/or notify the dev@solr.apache.org mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org