You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "andywebb1975 (via GitHub)" <gi...@apache.org> on 2023/02/02 13:28:43 UTC
[GitHub] [solr] andywebb1975 opened a new pull request, #1324: Add `reRankOperator` option to rerank query parser
andywebb1975 opened a new pull request, #1324:
URL: https://github.com/apache/solr/pull/1324
https://issues.apache.org/jira/browse/SOLR-16643
# Description
Add `reRankOperator=multiply` option to ReRank query parser
# Solution
The new option tells the `combine()` method to multiple rather than add the output of the ReRankQuery. The {{reRankWeight}} is ignored.
# Tests
I've added a test that validates that multiplication was applied to the score rather than addition.
# Checklist
Please review the following and check all that apply:
- [x] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [x] 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)
- [x] I have developed this patch against the `main` branch.
- [ ] I have run `./gradlew check`.
- [x] 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 still a draft PR for feedback - I'll run `check` now, and add to the docs.)
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1433376588
> Hi, @andywebb1975 . I pushed commit replacing switch to closure in doc scoring loop. Please have a look. WDYT?
Thanks @mkhludnev - yes, that does look cleaner!
--
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
[GitHub] [solr] cpoerschke commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "cpoerschke (via GitHub)" <gi...@apache.org>.
cpoerschke commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1095579544
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
minor: wondering about use of `String` vs. enum (which would also take care of handling of typos e.g. `reRankOperator=multi` would throw an exception rather than be silently treated as `add`)
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -99,6 +109,7 @@ protected float combine(
private static final class ReRankQuery extends AbstractReRankQuery {
private final Query reRankQuery;
private final double reRankWeight;
+ private final String reRankOperator;
@Override
public int hashCode() {
Review Comment:
minor: should we also consider the `reRankOperator` here?
##########
solr/solr-ref-guide/modules/query-guide/pages/query-re-ranking.adoc:
##########
@@ -67,7 +67,7 @@ This number will be treated as a minimum, and may be increased internally automa
|Optional |Default: `2.0`
|===
+
-A multiplicative factor that will be applied to the score from the reRankQuery for each of the top matching documents, before that score is added to the original score.
+A multiplicative factor that will be applied to the score from the reRankQuery for each of the top matching documents, before that score is combined with the original score.
In the example below, the top 1000 documents matching the query "greetings" will be re-ranked using the query "(hi hello hey hiya)".
The resulting scores for each of those 1000 documents will be 3 times their score from the "(hi hello hey hiya)", plus the score from the original "greetings" query:
Review Comment:
subjective: perhaps an additional example could be added where _"... plus the score ..."_ then is _"... times the score ..."_
--
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
[GitHub] [solr] mkhludnev commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1454685739
Congratulations, @andywebb1975!
Pushing both altogether makes more sense to me.
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1435271833
> ok. @andywebb1975 I noticed your contributor label! Can you squash-merge it on your own?
Sure, have just squashed it. I'm just a contributor - don't have committer rights, if that's what you meant?
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1419588565
I've updated this to use an `enum` following one of the examples above - how does it look now?
(I've seen `gradlew check` work locally but Crave.io seems to be having issues :-( )
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1454711385
I've made a new PR introducing both options: https://github.com/apache/solr/pull/1431 - could you give that a review please?
(It felt cleaner to raise a new PR, though now I'm not sure that was the best thing to do!)
--
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
[GitHub] [solr] andywebb1975 commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1095910424
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -99,6 +109,7 @@ protected float combine(
private static final class ReRankQuery extends AbstractReRankQuery {
private final Query reRankQuery;
private final double reRankWeight;
+ private final String reRankOperator;
@Override
public int hashCode() {
Review Comment:
Do you mean in the `hashCode`? Probably yes - I'd not noticed that! I'll have to familiarise myself with what that's for.
--
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
[GitHub] [solr] cpoerschke commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "cpoerschke (via GitHub)" <gi...@apache.org>.
cpoerschke commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1097524675
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
Looks like `.valueOf` is the magic word e.g. like in https://github.com/apache/solr/blob/releases/solr/9.1.1/solr/core/src/java/org/apache/solr/cloud/overseer/OverseerAction.java say.
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1454682268
I have committer rights now - a massive thank you if you were involved in arranging this!
I'm wondering whether to merge this as-is, or supersede it with a version including a `reRankOperator=replace` option too: https://github.com/apache/solr/commit/8b6859728eb6b7d46df4d9be210319352835cf9b - that could be a separate ticket/PR but I think it'd be tidier in the change list to add both options at the same time. Any thoughts on this?
--
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
[GitHub] [solr] mkhludnev commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1431495141
Hi, @andywebb1975 . I pushed commit replacing switch to closure in doc scoring loop. Please have a look. WDYT?
--
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
[GitHub] [solr] mkhludnev commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1103228216
##########
solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java:
##########
@@ -126,6 +128,32 @@ public void testReRankQueries() {
"//result/doc[5]/str[@name='id'][.='1']",
"//result/doc[6]/str[@name='id'][.='5']");
+ // test with reRankOperator=multiply by checking score (the order doesn't change)
+ params = new ModifiableSolrParams();
+ params.add(
+ "rq",
+ "{!"
+ + ReRankQParserPlugin.NAME
+ + " "
+ + ReRankQParserPlugin.RERANK_QUERY
+ + "=$rqq "
+ + ReRankQParserPlugin.RERANK_OPERATOR
+ + "=multiply "
+ + ReRankQParserPlugin.RERANK_DOCS
+ + "=200}");
+ params.add("q", "term_s:YYYY^=0.1"); // force score=0.1
+ params.add("rqq", "{!edismax bf=$bff}*:*");
+ params.add("bff", "field(test_ti)"); // test_ti=5000 for item 3
+ params.add("start", "0");
+ params.add("rows", "6");
+ params.add("df", "text");
+ params.add("fl", "id,score");
+ assertQ(
+ req(params),
+ "*[count(//doc)=6]",
+ "//result/doc[1]/str[@name='id'][.='3']",
+ "//result/doc[1]/float[@name='score'][.='1000.2']"); // adding gives 10002.1 instead
Review Comment:
Why don't have explicit test case&assert for addition?
--
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
[GitHub] [solr] mkhludnev commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1435176616
ok. @andywebb1975 I noticed your contributor label! Can you squash-merge it on your own?
--
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
[GitHub] [solr] janhoy commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "janhoy (via GitHub)" <gi...@apache.org>.
janhoy commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1425467217
PS: You don't need to force-push to PR branch. In fact it may be better not to for review history. The final merge will be squashed into one commit anyway, so no worry about clean commit history.
--
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
[GitHub] [solr] mkhludnev commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1433670127
Oh.. somehow, I stepped in CHANGES. Colleagues, would you mind approve or point on some stuff to improve?
--
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
[GitHub] [solr] mkhludnev commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1436951521
> > ok. @andywebb1975 I noticed your contributor label! Can you squash-merge it on your own?
>
> Sure, have just squashed it. I'm just a contributor - don't have committer rights, if that's what you meant?
Ok. I've thought you can push. My bad.
--
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
[GitHub] [solr] andywebb1975 commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1095911296
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
Good idea, yes - I'll look into that.
--
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
[GitHub] [solr] andywebb1975 commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1097178117
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
Do you know if there are other examples of enum-based params in Solr? I've changed the code to validate the value, but couldn't see how to use enums for this. (I'm not a strong Java programmer!)
--
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
[GitHub] [solr] mkhludnev commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1096982867
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
enums will also help later to introduce other ops like min, max, etc
--
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
[GitHub] [solr] andywebb1975 commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1103629953
##########
solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java:
##########
@@ -126,6 +128,32 @@ public void testReRankQueries() {
"//result/doc[5]/str[@name='id'][.='1']",
"//result/doc[6]/str[@name='id'][.='5']");
+ // test with reRankOperator=multiply by checking score (the order doesn't change)
+ params = new ModifiableSolrParams();
+ params.add(
+ "rq",
+ "{!"
+ + ReRankQParserPlugin.NAME
+ + " "
+ + ReRankQParserPlugin.RERANK_QUERY
+ + "=$rqq "
+ + ReRankQParserPlugin.RERANK_OPERATOR
+ + "=multiply "
+ + ReRankQParserPlugin.RERANK_DOCS
+ + "=200}");
+ params.add("q", "term_s:YYYY^=0.1"); // force score=0.1
+ params.add("rqq", "{!edismax bf=$bff}*:*");
+ params.add("bff", "field(test_ti)"); // test_ti=5000 for item 3
+ params.add("start", "0");
+ params.add("rows", "6");
+ params.add("df", "text");
+ params.add("fl", "id,score");
+ assertQ(
+ req(params),
+ "*[count(//doc)=6]",
+ "//result/doc[1]/str[@name='id'][.='3']",
+ "//result/doc[1]/float[@name='score'][.='1000.2']"); // adding gives 10002.1 instead
Review Comment:
That's a good shout - I've added one.
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1435108644
> Oh.. somehow, I stepped in CHANGES. Colleagues, would you mind approve or point on some stuff to improve?
Is there anything I can do to help here? The update looks fine to me.
--
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
[GitHub] [solr] cpoerschke commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "cpoerschke (via GitHub)" <gi...@apache.org>.
cpoerschke commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1111680488
##########
solr/core/src/java/org/apache/solr/search/ReRankOperator.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.search;
+
+import java.util.Locale;
+import org.apache.solr.common.SolrException;
+
+public enum ReRankOperator {
+ ADD,
+ MULTIPLY;
+
+ public static ReRankOperator get(String p) {
+ if (p != null) {
+ try {
+ return ReRankOperator.valueOf(p.toUpperCase(Locale.ROOT));
+ } catch (Exception ex) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid reRankOperator");
Review Comment:
minor/subjective
```suggestion
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid reRankOperator: " + p);
```
##########
solr/core/src/java/org/apache/solr/search/ReRankOperator.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.search;
+
+import java.util.Locale;
+import org.apache.solr.common.SolrException;
+
+public enum ReRankOperator {
+ ADD,
+ MULTIPLY;
+
+ public static ReRankOperator get(String p) {
+ if (p != null) {
+ try {
+ return ReRankOperator.valueOf(p.toUpperCase(Locale.ROOT));
+ } catch (Exception ex) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid reRankOperator");
+ }
+ }
+ return null;
+ }
+
+ public boolean isEqual(String s) {
+ return s != null && toString().equals(s.toUpperCase(Locale.ROOT));
+ }
+
Review Comment:
Wondering if this code is unused?
```suggestion
```
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -68,29 +71,48 @@ public Query parse() throws SyntaxError {
Query reRankQuery = reRankParser.parse();
int reRankDocs = localParams.getInt(RERANK_DOCS, RERANK_DOCS_DEFAULT);
- reRankDocs = Math.max(1, reRankDocs); //
+ reRankDocs = Math.max(1, reRankDocs);
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ ReRankOperator reRankOperator =
+ ReRankOperator.get(localParams.get(RERANK_OPERATOR, RERANK_OPERATOR_DEFAULT));
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
- final double reRankWeight;
+ final BiFloatFunction scoreCombiner;
+
+ @FunctionalInterface
+ interface BiFloatFunction {
+ float func(float a, float b);
+ }
- public ReRankQueryRescorer(Query reRankQuery, double reRankWeight) {
+ public ReRankQueryRescorer(
+ Query reRankQuery, double reRankWeight, ReRankOperator reRankOperator) {
super(reRankQuery);
- this.reRankWeight = reRankWeight;
+ switch (reRankOperator) {
+ case ADD:
+ scoreCombiner = (score, second) -> (float) (score + reRankWeight * second);
+ break;
+ case MULTIPLY:
+ scoreCombiner = (score, second) -> (float) (score * reRankWeight * second);
+ break;
+ default:
+ scoreCombiner = null;
+ throw new IllegalArgumentException("Unexpected:" + reRankOperator);
Review Comment:
```suggestion
throw new IllegalArgumentException("Unexpected: reRankOperator=" + reRankOperator);
```
##########
solr/core/src/test/org/apache/solr/search/TestReRankQParserPlugin.java:
##########
@@ -126,6 +128,58 @@ public void testReRankQueries() {
"//result/doc[5]/str[@name='id'][.='1']",
"//result/doc[6]/str[@name='id'][.='5']");
+ // test with reRankOperator=add by checking score (the order doesn't change)
+ params = new ModifiableSolrParams();
+ params.add(
+ "rq",
+ "{!"
+ + ReRankQParserPlugin.NAME
+ + " "
+ + ReRankQParserPlugin.RERANK_QUERY
+ + "=$rqq "
+ + ReRankQParserPlugin.RERANK_OPERATOR
+ + "=add "
+ + ReRankQParserPlugin.RERANK_DOCS
+ + "=200}");
+ params.add("q", "term_s:YYYY^=0.1"); // force score=0.1
+ params.add("rqq", "{!edismax bf=$bff}*:*");
+ params.add("bff", "field(test_ti)"); // test_ti=5000 for item 3
+ params.add("start", "0");
+ params.add("rows", "6");
+ params.add("df", "text");
+ params.add("fl", "id,score");
+ assertQ(
+ req(params),
+ "*[count(//doc)=6]",
+ "//result/doc[1]/str[@name='id'][.='3']",
+ "//result/doc[1]/float[@name='score'][.='10002.1']"); // multiplying gives 1000.2 instead
+
+ // test with reRankOperator=multiply by checking score (the order doesn't change)
+ params = new ModifiableSolrParams();
+ params.add(
+ "rq",
+ "{!"
+ + ReRankQParserPlugin.NAME
+ + " "
+ + ReRankQParserPlugin.RERANK_QUERY
+ + "=$rqq "
+ + ReRankQParserPlugin.RERANK_OPERATOR
+ + "=multiply "
Review Comment:
Perhaps `mult` could be an additional test case i.e. to test error handling and that `mult-instead-of-multiply` or typos will explicitly fail and not be silently be treated as `add`.
--
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
[GitHub] [solr] andywebb1975 commented on pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 commented on PR #1324:
URL: https://github.com/apache/solr/pull/1324#issuecomment-1458609616
superseded by https://github.com/apache/solr/pull/1431
--
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
[GitHub] [solr] andywebb1975 closed pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "andywebb1975 (via GitHub)" <gi...@apache.org>.
andywebb1975 closed pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
URL: https://github.com/apache/solr/pull/1324
--
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
[GitHub] [solr] mkhludnev commented on a diff in pull request #1324: SOLR-16643: Add multiplying boost option to rerank query parser
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on code in PR #1324:
URL: https://github.com/apache/solr/pull/1324#discussion_r1097437061
##########
solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java:
##########
@@ -72,25 +74,33 @@ public Query parse() throws SyntaxError {
double reRankWeight = localParams.getDouble(RERANK_WEIGHT, RERANK_WEIGHT_DEFAULT);
- return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight);
+ String reRankOperator = localParams.get(RERANK_OPERATOR, "add");
+
+ return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, reRankOperator);
}
}
private static final class ReRankQueryRescorer extends QueryRescorer {
final double reRankWeight;
+ final String reRankOperator;
Review Comment:
Hello, Andy.
Thanks for your effort. I think you can check here https://github.com/apache/solr/blob/main/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java#L213.
--
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