mkhludnev commented on code in PR #1260:
URL: https://github.com/apache/solr/pull/1260#discussion_r1111240673
##########
solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java:
##########
@@ -127,6 +128,53 @@ public void process(ResponseBuilder rb) throws IOException
{
}
}
+ private static NamedList<String> putMLTIntoParamList(
+ IndexSchema schema,
+ List<MoreLikeThisHandler.InterestingTerm> terms,
+ String uniqueField,
+ String uniqueVal) {
+ final NamedList<String> mltQ = new NamedList<>();
+ StringBuilder q = new StringBuilder("{!bool");
+ q.append(" must_not=$");
+ int cnt = 0;
+ String param = "mltq" + (cnt++);
+ q.append(param);
+ mltQ.add(param, "{!field f=" + uniqueField + "}" + uniqueVal);
+ final StringBuilder reuseStr = new StringBuilder();
+ final CharsRefBuilder reuseChar = new CharsRefBuilder();
+ for (MoreLikeThisHandler.InterestingTerm term : terms) {
+ param = "mltq" + (cnt++);
+ q.append(" should=$");
+ q.append(param);
+ mltQ.add(param, toParserParam(schema, term.term, term.boost, reuseStr,
reuseChar));
+ }
+ q.append("}");
+ mltQ.add(CommonParams.Q, q.toString());
+ return mltQ;
+ }
+
+ private static String toParserParam(
+ IndexSchema schema,
+ Term term1,
+ float boost,
+ StringBuilder reuseStr,
+ CharsRefBuilder reuseChar) {
+ reuseStr.setLength(0);
+ if (boost != 1f) {
+ reuseStr.append("{!boost b=");
+ reuseStr.append(boost);
+ reuseStr.append("}");
+ }
+ final String field = term1.field();
+ final CharsRef val =
Review Comment:
Thanks for suggestion, but I don't think it often matters much for field
name.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]