From 4edfc1a9c7b877a23cffbf5f73a2728173fa663d Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Thu, 23 Mar 2017 18:12:20 +1030 Subject: [PATCH] SOLR-6615: use constants for 'sort', 'distrib' --- .../solr/response/VelocityResponseWriter.java | 4 ++- .../org/apache/solr/cloud/SyncStrategy.java | 4 ++- .../apache/solr/core/QuerySenderListener.java | 26 ++++++++++--------- .../org/apache/solr/handler/BlobHandler.java | 3 ++- .../org/apache/solr/handler/GraphHandler.java | 4 ++- .../solr/handler/PingRequestHandler.java | 6 +++-- .../apache/solr/handler/StreamHandler.java | 3 ++- .../component/IterativeMergeStrategy.java | 4 ++- .../component/MoreLikeThisComponent.java | 4 ++- .../component/RealTimeGetComponent.java | 3 ++- .../solr/handler/component/SearchHandler.java | 5 ++-- .../apache/solr/handler/sql/SolrTable.java | 11 ++++---- .../solr/index/SortingMergePolicyFactory.java | 7 +++-- .../org/apache/solr/request/SimpleFacets.java | 4 ++- .../apache/solr/request/json/RequestUtil.java | 5 ++-- .../solr/search/CollapsingQParserPlugin.java | 15 ++++++----- .../solr/search/facet/FacetRequest.java | 3 ++- .../apache/solr/search/facet/LegacyFacet.java | 8 +++--- .../java/org/apache/solr/update/PeerSync.java | 11 ++++---- .../processor/DistributedUpdateProcessor.java | 3 ++- .../java/org/apache/solr/util/SolrCLI.java | 3 ++- .../solr/client/solrj/io/ModelCache.java | 3 ++- .../solrj/io/graph/GatherNodesStream.java | 4 ++- .../solrj/io/graph/ShortestPathStream.java | 4 ++- .../client/solrj/io/ops/GroupOperation.java | 6 +++-- .../solrj/io/stream/CloudSolrStream.java | 9 ++++--- .../io/stream/FeaturesSelectionStream.java | 3 ++- .../client/solrj/io/stream/FetchStream.java | 3 ++- .../client/solrj/io/stream/JDBCStream.java | 8 +++--- .../solrj/io/stream/ParallelStream.java | 13 ++++++---- .../client/solrj/io/stream/RandomStream.java | 14 +++++----- .../client/solrj/io/stream/RankStream.java | 6 +++-- .../solrj/io/stream/ScoreNodesStream.java | 6 +++-- .../io/stream/SignificantTermsStream.java | 4 ++- .../solrj/io/stream/TextLogitStream.java | 3 ++- .../client/solrj/io/stream/TopicStream.java | 10 ++++--- .../solr/common/params/TermsParams.java | 12 +++++---- 37 files changed, 151 insertions(+), 93 deletions(-) diff --git a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java index 7a0f2a10552..e7cc9b7fb15 100644 --- a/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java +++ b/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java @@ -58,6 +58,8 @@ import org.apache.velocity.tools.generic.SortTool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAware { // init param names, these are _only_ loaded at init time (no per-request control of these) // - multiple different named writers could be created with different init params @@ -204,7 +206,7 @@ public class VelocityResponseWriter implements QueryResponseWriter, SolrCoreAwar context.put("esc", new EscapeTool()); context.put("date", new ComparisonDateTool()); context.put("list", new ListTool()); - context.put("sort", new SortTool()); + context.put(SORT, new SortTool()); MathTool mathTool = new MathTool(); mathTool.configure(toolConfig); diff --git a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java index 6356da77f00..386fef9e5f7 100644 --- a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java +++ b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java @@ -44,6 +44,8 @@ import org.apache.solr.update.UpdateShardHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; + public class SyncStrategy { private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -258,7 +260,7 @@ public class SyncStrategy { sreq.actualShards = sreq.shards; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt","/get"); - sreq.params.set("distrib",false); + sreq.params.set(DISTRIB,false); sreq.params.set("getVersions",Integer.toString(nUpdates)); sreq.params.set("sync",leaderUrl); diff --git a/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java b/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java index a5cda61bdf6..9037ef3122c 100644 --- a/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java +++ b/solr/core/src/java/org/apache/solr/core/QuerySenderListener.java @@ -16,21 +16,23 @@ */ package org.apache.solr.core; -import org.apache.solr.request.SolrQueryRequest; -import org.apache.solr.request.SolrRequestInfo; -import org.apache.solr.response.ResultContext; -import org.apache.solr.search.SolrIndexSearcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.solr.search.DocList; -import org.apache.solr.search.DocIterator; +import java.lang.invoke.MethodHandles; +import java.util.List; + import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.request.LocalSolrQueryRequest; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.request.SolrRequestInfo; +import org.apache.solr.response.ResultContext; import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.search.DocIterator; +import org.apache.solr.search.DocList; +import org.apache.solr.search.SolrIndexSearcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; -import java.util.List; +import static org.apache.solr.common.params.CommonParams.DISTRIB; /** * @@ -55,8 +57,8 @@ public class QuerySenderListener extends AbstractSolrEventListener { // bind the request to a particular searcher (the newSearcher) NamedList params = addEventParms(currentSearcher, nlst); // for this, we default to distrib = false - if (params.get("distrib") == null) { - params.add("distrib", false); + if (params.get(DISTRIB) == null) { + params.add(DISTRIB, false); } req = new LocalSolrQueryRequest(getCore(),params) { @Override public SolrIndexSearcher getSearcher() { return searcher; } diff --git a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java index 7e97f5953f4..052fcfee48e 100644 --- a/solr/core/src/java/org/apache/solr/handler/BlobHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/BlobHandler.java @@ -66,6 +66,7 @@ import org.slf4j.LoggerFactory; import static java.util.Collections.singletonMap; import static org.apache.solr.common.params.CommonParams.ID; import static org.apache.solr.common.params.CommonParams.JSON; +import static org.apache.solr.common.params.CommonParams.SORT; import static org.apache.solr.common.params.CommonParams.VERSION; import static org.apache.solr.common.util.Utils.makeMap; @@ -204,7 +205,7 @@ public class BlobHandler extends RequestHandlerBase implements PluginInfoInitial new MapSolrParams((Map) makeMap( "q", StrUtils.formatString(q, blobName, version), "fl", "id,size,version,timestamp,blobName,md5", - "sort", "version desc")) + SORT, "version desc")) , rsp); } } diff --git a/solr/core/src/java/org/apache/solr/handler/GraphHandler.java b/solr/core/src/java/org/apache/solr/handler/GraphHandler.java index 3b521547c81..6d41d830840 100644 --- a/solr/core/src/java/org/apache/solr/handler/GraphHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/GraphHandler.java @@ -57,6 +57,8 @@ import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, PermissionNameProvider { private StreamFactory streamFactory = new StreamFactory(); @@ -118,7 +120,7 @@ public class GraphHandler extends RequestHandlerBase implements SolrCoreAware, P .withFunctionName("shortestPath", ShortestPathStream.class) .withFunctionName("gatherNodes", GatherNodesStream.class) .withFunctionName("nodes", GatherNodesStream.class) - .withFunctionName("sort", SortStream.class) + .withFunctionName(SORT, SortStream.class) .withFunctionName("scoreNodes", ScoreNodesStream.class) .withFunctionName("random", RandomStream.class) diff --git a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java index 8230bf5d6be..0cd9e1d57ef 100644 --- a/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java @@ -38,6 +38,8 @@ import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; + /** * Ping Request Handler for reporting SolrCore health to a Load Balancer. * @@ -180,10 +182,10 @@ public class PingRequestHandler extends RequestHandlerBase implements SolrCoreAw // in this case, we want to default distrib to false so // we only ping the single node - Boolean distrib = params.getBool("distrib"); + Boolean distrib = params.getBool(DISTRIB); if (distrib == null) { ModifiableSolrParams mparams = new ModifiableSolrParams(params); - mparams.set("distrib", false); + mparams.set(DISTRIB, false); req.setParams(mparams); } diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java index a25ede46e17..5d10664debf 100644 --- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java @@ -81,6 +81,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static org.apache.solr.common.params.CommonParams.ID; +import static org.apache.solr.common.params.CommonParams.SORT; public class StreamHandler extends RequestHandlerBase implements SolrCoreAware, PermissionNameProvider { @@ -148,7 +149,7 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware, .withFunctionName("outerHashJoin", OuterHashJoinStream.class) .withFunctionName("intersect", IntersectStream.class) .withFunctionName("complement", ComplementStream.class) - .withFunctionName("sort", SortStream.class) + .withFunctionName(SORT, SortStream.class) .withFunctionName("train", TextLogitStream.class) .withFunctionName("features", FeaturesSelectionStream.class) .withFunctionName("daemon", DaemonStream.class) diff --git a/solr/core/src/java/org/apache/solr/handler/component/IterativeMergeStrategy.java b/solr/core/src/java/org/apache/solr/handler/component/IterativeMergeStrategy.java index 2138948f93a..97d4199a114 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/IterativeMergeStrategy.java +++ b/solr/core/src/java/org/apache/solr/handler/component/IterativeMergeStrategy.java @@ -38,6 +38,8 @@ import org.apache.http.client.HttpClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; + public abstract class IterativeMergeStrategy implements MergeStrategy { protected ExecutorService executorService; @@ -89,7 +91,7 @@ public abstract class IterativeMergeStrategy implements MergeStrategy { this.originalShardResponse = originalShardResponse; req.setMethod(SolrRequest.METHOD.POST); ModifiableSolrParams params = (ModifiableSolrParams)req.getParams(); - params.add("distrib", "false"); + params.add(DISTRIB, "false"); } public QueryResponse getResponse() { diff --git a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java index 55edc631114..ffb58588907 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java @@ -51,6 +51,8 @@ import org.apache.solr.search.SolrReturnFields; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * TODO! * @@ -339,7 +341,7 @@ public class MoreLikeThisComponent extends SearchComponent { String id = rb.req.getSchema().getUniqueKeyField() .getName(); s.params.set(CommonParams.FL, "score," + id); - s.params.set("sort", "score desc"); + s.params.set(SORT, "score desc"); // MLT Query is submitted as normal query to shards. s.params.set(CommonParams.Q, q); diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java index 12aa4033d14..421e74fc917 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java @@ -82,6 +82,7 @@ import org.apache.solr.util.RefCounted; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.ID; import static org.apache.solr.common.params.CommonParams.VERSION_FIELD; @@ -840,7 +841,7 @@ public class RealTimeGetComponent extends SearchComponent // TODO: how to avoid hardcoding this and hit the same handler? sreq.params.set(ShardParams.SHARDS_QT,"/get"); - sreq.params.set("distrib",false); + sreq.params.set(DISTRIB,false); sreq.params.remove(ShardParams.SHARDS); sreq.params.remove(ID); diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java index c05c6c42670..a00839b1e85 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java @@ -53,6 +53,7 @@ import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.PATH; @@ -212,7 +213,7 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware , CoreContainer cc = req.getCore().getCoreDescriptor().getCoreContainer(); boolean isZkAware = cc.isZooKeeperAware(); - rb.isDistrib = req.getParams().getBool("distrib", isZkAware); + rb.isDistrib = req.getParams().getBool(DISTRIB, isZkAware); if (!rb.isDistrib) { // for back compat, a shards param with URLs like localhost:8983/solr will mean that this // search is distributed. @@ -361,7 +362,7 @@ public class SearchHandler extends RequestHandlerBase implements SolrCoreAware , for (String shard : sreq.actualShards) { ModifiableSolrParams params = new ModifiableSolrParams(sreq.params); params.remove(ShardParams.SHARDS); // not a top-level request - params.set(CommonParams.DISTRIB, "false"); // not a top-level request + params.set(DISTRIB, "false"); // not a top-level request params.remove("indent"); params.remove(CommonParams.HEADER_ECHO_PARAMS); params.set(ShardParams.IS_SHARD, true); // a sub (shard) request diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java index c3b83dbdd83..e313b440ce7 100644 --- a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java +++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java @@ -55,6 +55,7 @@ import org.apache.solr.common.params.ModifiableSolrParams; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; +import static org.apache.solr.common.params.CommonParams.SORT; /** * Table based on a Solr collection @@ -271,13 +272,13 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable { String fl = getFields(fields); if(orders.size() > 0) { - params.add(CommonParams.SORT, getSort(orders)); + params.add(SORT, getSort(orders)); } else { if(limit == null) { - params.add(CommonParams.SORT, "_version_ desc"); + params.add(SORT, "_version_ desc"); fl = fl+",_version_"; } else { - params.add(CommonParams.SORT, "score desc"); + params.add(SORT, "score desc"); if(fl.indexOf("score") == -1) { fl = fl + ",score"; } @@ -460,7 +461,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable { params.set("partitionKeys", getPartitionKeys(buckets)); } - params.set("sort", sort); + params.set(SORT, sort); TupleStream tupleStream = null; @@ -699,7 +700,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable { params.set("partitionKeys", getPartitionKeys(buckets)); } - params.set("sort", sort); + params.set(SORT, sort); TupleStream tupleStream = null; diff --git a/solr/core/src/java/org/apache/solr/index/SortingMergePolicyFactory.java b/solr/core/src/java/org/apache/solr/index/SortingMergePolicyFactory.java index b22df3b3f97..ea2387d5914 100644 --- a/solr/core/src/java/org/apache/solr/index/SortingMergePolicyFactory.java +++ b/solr/core/src/java/org/apache/solr/index/SortingMergePolicyFactory.java @@ -18,25 +18,24 @@ package org.apache.solr.index; import org.apache.lucene.index.MergePolicy; import org.apache.lucene.search.Sort; - import org.apache.solr.core.SolrResourceLoader; import org.apache.solr.schema.IndexSchema; import org.apache.solr.search.SortSpecParsing; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * A {@link MergePolicyFactory} for {@code SortingMergePolicy} objects. */ public class SortingMergePolicyFactory extends WrapperMergePolicyFactory { - static final String SORT = "sort"; // not private so that test(s) can use it - protected final Sort mergeSort; public SortingMergePolicyFactory(SolrResourceLoader resourceLoader, MergePolicyFactoryArgs args, IndexSchema schema) { super(resourceLoader, args, schema); final String sortArg = (String) args.remove(SORT); if (sortArg == null) { - throw new IllegalArgumentException(SortingMergePolicyFactory.class.getSimpleName()+" requires a '"+SORT+ "' argument."); + throw new IllegalArgumentException(SortingMergePolicyFactory.class.getSimpleName()+" requires a '"+ SORT + "' argument."); } this.mergeSort = SortSpecParsing.parseSortSpec(sortArg, schema).getSort(); } diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java index 5370dd9f3f9..b452802cad1 100644 --- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java +++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java @@ -96,6 +96,8 @@ import org.apache.solr.util.BoundedTreeSet; import org.apache.solr.util.DefaultSolrThreadFactory; import org.apache.solr.util.RTimer; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * A class that generates simple Facet information for a request. * @@ -531,7 +533,7 @@ public class SimpleFacets { default: sortVal = sort; } - jsonFacet.put("sort", sortVal ); + jsonFacet.put(SORT, sortVal ); Map topLevel = new HashMap<>(); topLevel.put(field, jsonFacet); diff --git a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java index 2529e74f589..ac0dc1951ab 100644 --- a/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java +++ b/solr/core/src/java/org/apache/solr/request/json/RequestUtil.java @@ -36,6 +36,7 @@ import org.noggit.JSONParser; import org.noggit.ObjectBuilder; import static org.apache.solr.common.params.CommonParams.JSON; +import static org.apache.solr.common.params.CommonParams.SORT; public class RequestUtil { /** @@ -206,8 +207,8 @@ public class RequestUtil { out = "start"; } else if ("limit".equals(key)) { out = "rows"; - } else if ("sort".equals(key)) { - out = "sort"; + } else if (SORT.equals(key)) { + out = SORT; } else if ("params".equals(key) || "facet".equals(key) ) { // handled elsewhere continue; diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java index 22f9f29e12b..61756ea9251 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -25,6 +25,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import com.carrotsearch.hppc.FloatArrayList; +import com.carrotsearch.hppc.IntArrayList; +import com.carrotsearch.hppc.IntIntHashMap; +import com.carrotsearch.hppc.IntLongHashMap; +import com.carrotsearch.hppc.cursors.IntIntCursor; +import com.carrotsearch.hppc.cursors.IntLongCursor; import org.apache.commons.lang.StringUtils; import org.apache.lucene.codecs.DocValuesProducer; import org.apache.lucene.index.DocValues; @@ -72,12 +78,7 @@ import org.apache.solr.schema.TrieIntField; import org.apache.solr.schema.TrieLongField; import org.apache.solr.uninverting.UninvertingReader; -import com.carrotsearch.hppc.FloatArrayList; -import com.carrotsearch.hppc.IntArrayList; -import com.carrotsearch.hppc.IntIntHashMap; -import com.carrotsearch.hppc.IntLongHashMap; -import com.carrotsearch.hppc.cursors.IntIntCursor; -import com.carrotsearch.hppc.cursors.IntLongCursor; +import static org.apache.solr.common.params.CommonParams.SORT; /** @@ -187,7 +188,7 @@ public class CollapsingQParserPlugin extends QParserPlugin { * returns a new GroupHeadSelector based on the specified local params */ public static GroupHeadSelector build(final SolrParams localParams) { - final String sortString = StringUtils.defaultIfBlank(localParams.get("sort"), null); + final String sortString = StringUtils.defaultIfBlank(localParams.get(SORT), null); final String max = StringUtils.defaultIfBlank(localParams.get("max"), null); final String min = StringUtils.defaultIfBlank(localParams.get("min"), null); diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java index 9835f7d7165..b446ecea8c6 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRequest.java @@ -36,6 +36,7 @@ import org.apache.solr.search.QueryContext; import org.apache.solr.search.SolrIndexSearcher; import org.apache.solr.search.SyntaxError; +import static org.apache.solr.common.params.CommonParams.SORT; import static org.apache.solr.search.facet.FacetRequest.RefineMethod.NONE; @@ -645,7 +646,7 @@ class FacetFieldParser extends FacetParser { Object o = m.get("facet"); parseSubs(o); - parseSort( m.get("sort") ); + parseSort( m.get(SORT) ); } return facet; diff --git a/solr/core/src/java/org/apache/solr/search/facet/LegacyFacet.java b/solr/core/src/java/org/apache/solr/search/facet/LegacyFacet.java index 9457d9c4cc0..7c2bde46948 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/LegacyFacet.java +++ b/solr/core/src/java/org/apache/solr/search/facet/LegacyFacet.java @@ -35,6 +35,8 @@ import org.apache.solr.search.SolrReturnFields; import org.apache.solr.search.StrParser; import org.apache.solr.search.SyntaxError; +import static org.apache.solr.common.params.CommonParams.SORT; + public class LegacyFacet { private SolrParams params; private Map json; @@ -172,7 +174,7 @@ public class LegacyFacet { String sort = params.getFieldParam(f, FacetParams.FACET_SORT, limit>0 ? FacetParams.FACET_SORT_COUNT : FacetParams.FACET_SORT_INDEX); String prefix = params.getFieldParam(f, FacetParams.FACET_PREFIX); - Map cmd = new HashMap(); + Map cmd = new HashMap<>(); cmd.put("field", facetValue); if (offset != 0) cmd.put("offset", offset); if (limit != 10) cmd.put("limit", limit); @@ -182,9 +184,9 @@ public class LegacyFacet { if (sort.equals("count")) { // our default } else if (sort.equals("index")) { - cmd.put("sort", "index asc"); + cmd.put(SORT, "index asc"); } else { - cmd.put("sort", sort); // can be sort by one of our stats + cmd.put(SORT, sort); // can be sort by one of our stats } Map type = new HashMap<>(1); diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java b/solr/core/src/java/org/apache/solr/update/PeerSync.java index 425d1dbbe68..9470cca41be 100644 --- a/solr/core/src/java/org/apache/solr/update/PeerSync.java +++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java @@ -60,6 +60,7 @@ import org.apache.solr.update.processor.UpdateRequestProcessorChain; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.ID; import static org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase.FROMLEADER; import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM; @@ -405,7 +406,7 @@ public class PeerSync implements SolrMetricProducer { sreq.params = new ModifiableSolrParams(); sreq.params = new ModifiableSolrParams(); sreq.params.set("qt","/get"); - sreq.params.set("distrib",false); + sreq.params.set(DISTRIB,false); sreq.params.set("getFingerprint", String.valueOf(Long.MAX_VALUE)); shardHandler.submit(sreq, replica, sreq.params); @@ -421,7 +422,7 @@ public class PeerSync implements SolrMetricProducer { sreq.actualShards = sreq.shards; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt","/get"); - sreq.params.set("distrib",false); + sreq.params.set(DISTRIB,false); sreq.params.set("getVersions",nUpdates); sreq.params.set("fingerprint",doFingerprint); shardHandler.submit(sreq, replica, sreq.params); @@ -506,7 +507,7 @@ public class PeerSync implements SolrMetricProducer { sreq.actualShards = sreq.shards; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt", "/get"); - sreq.params.set("distrib", false); + sreq.params.set(DISTRIB, false); sreq.params.set("checkCanHandleVersionRanges", false); ShardHandler sh = shardHandlerFactory.getShardHandler(client); @@ -725,7 +726,7 @@ public class PeerSync implements SolrMetricProducer { sreq.purpose = 0; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt", "/get"); - sreq.params.set("distrib", false); + sreq.params.set(DISTRIB, false); sreq.params.set("getUpdates", versionsAndRanges); sreq.params.set("onlyIfActive", onlyIfActive); @@ -890,7 +891,7 @@ public class PeerSync implements SolrMetricProducer { sreq.shards = new String[]{replica}; sreq.params = new ModifiableSolrParams(); sreq.params.set("qt","/get"); - sreq.params.set("distrib", false); + sreq.params.set(DISTRIB, false); sreq.params.set("getVersions",nUpdates); shardHandler.submit(sreq, replica, sreq.params); } diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java index fe71b0b805f..55d1fc8c032 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java +++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java @@ -16,6 +16,7 @@ */ package org.apache.solr.update.processor; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.update.processor.DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM; import java.io.IOException; @@ -1303,7 +1304,7 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor { String id = inplaceAdd.getPrintableId(); UpdateShardHandler updateShardHandler = inplaceAdd.getReq().getCore().getCoreDescriptor().getCoreContainer().getUpdateShardHandler(); ModifiableSolrParams params = new ModifiableSolrParams(); - params.set("distrib", false); + params.set(DISTRIB, false); params.set("getInputDocument", id); params.set("onlyIfActive", true); SolrRequest ur = new GenericSolrRequest(METHOD.GET, "/get", params); diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java index 4f6cf8dfae1..6a85422185d 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java +++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java @@ -113,6 +113,7 @@ import org.slf4j.LoggerFactory; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.solr.common.SolrException.ErrorCode.FORBIDDEN; import static org.apache.solr.common.SolrException.ErrorCode.UNAUTHORIZED; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.NAME; /** @@ -1193,7 +1194,7 @@ public class SolrCLI { // query this replica directly to get doc count and assess health q = new SolrQuery("*:*"); q.setRows(0); - q.set("distrib", "false"); + q.set(DISTRIB, "false"); try (HttpSolrClient solr = new HttpSolrClient.Builder(coreUrl).build()) { String solrUrl = solr.getBaseURL(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ModelCache.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ModelCache.java index 9a204e26808..4676594835b 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ModelCache.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ModelCache.java @@ -25,6 +25,7 @@ import org.apache.solr.client.solrj.io.stream.CloudSolrStream; import org.apache.solr.client.solrj.io.stream.StreamContext; import org.apache.solr.common.params.ModifiableSolrParams; +import static org.apache.solr.common.params.CommonParams.SORT; import static org.apache.solr.common.params.CommonParams.VERSION_FIELD; @@ -74,7 +75,7 @@ public class ModelCache { ModifiableSolrParams params = new ModifiableSolrParams(); params.set("q","name_s:"+modelID); params.set("fl", "terms_ss, idfs_ds, weights_ds, iteration_i, _version_"); - params.set("sort", "iteration_i desc"); + params.set(SORT, "iteration_i desc"); StreamContext streamContext = new StreamContext(); streamContext.setSolrClientCache(solrClientCache); CloudSolrStream stream = new CloudSolrStream(zkHost, collection, params); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java index 52a6a1ed392..805967775a0 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java @@ -51,6 +51,8 @@ import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SolrjNamedThreadFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + public class GatherNodesStream extends TupleStream implements Expressible { private String zkHost; @@ -449,7 +451,7 @@ public class GatherNodesStream extends TupleStream implements Expressible { ModifiableSolrParams joinSParams = new ModifiableSolrParams(SolrParams.toMultiMap(new NamedList(queryParams))); joinSParams.set("fl", buf.toString()); joinSParams.set("qt", "/export"); - joinSParams.set("sort", gather + " asc,"+traverseTo +" asc"); + joinSParams.set(SORT, gather + " asc,"+traverseTo +" asc"); StringBuffer nodeQuery = new StringBuffer(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java index 768ce07ebb5..aa546ae9e0c 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/ShortestPathStream.java @@ -52,6 +52,8 @@ import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrjNamedThreadFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + public class ShortestPathStream extends TupleStream implements Expressible { private static final long serialVersionUID = 1; @@ -450,7 +452,7 @@ public class ShortestPathStream extends TupleStream implements Expressible { joinParams.set("fl", fl); joinParams.set("qt", "/export"); - joinParams.set("sort", toField + " asc,"+fromField +" asc"); + joinParams.set(SORT, toField + " asc,"+fromField +" asc"); StringBuffer nodeQuery = new StringBuffer(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java index 9ed5cbe29be..4a28cc1e0fd 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GroupOperation.java @@ -39,6 +39,8 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter; import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue; import org.apache.solr.client.solrj.io.stream.expr.StreamFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + public class GroupOperation implements ReduceOperation { private static final long serialVersionUID = 1L; @@ -52,7 +54,7 @@ public class GroupOperation implements ReduceOperation { public GroupOperation(StreamExpression expression, StreamFactory factory) throws IOException { StreamExpressionNamedParameter nParam = factory.getNamedOperand(expression, "n"); - StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, "sort"); + StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, SORT); StreamComparator streamComparator = factory.constructComparator(((StreamExpressionValue) sortExpression.getParameter()).getValue(), FieldComparator.class); String nStr = ((StreamExpressionValue)nParam.getParameter()).getValue(); @@ -87,7 +89,7 @@ public class GroupOperation implements ReduceOperation { expression.addParameter(new StreamExpressionNamedParameter("n", Integer.toString(size))); // sort - expression.addParameter(new StreamExpressionNamedParameter("sort", streamComparator.toExpression(factory))); + expression.addParameter(new StreamExpressionNamedParameter(SORT, streamComparator.toExpression(factory))); return expression; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java index f177585e2a3..1acd79dff63 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java @@ -63,6 +63,9 @@ import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.SolrjNamedThreadFactory; import org.apache.solr.common.util.StrUtils; +import static org.apache.solr.common.params.CommonParams.DISTRIB; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * Connects to Zookeeper to pick replicas from a specific collection to send the query to. * Under the covers the SolrStream instances send the query to the replicas. @@ -269,10 +272,10 @@ public class CloudSolrStream extends TupleStream implements Expressible { } String fls = String.join(",", params.getParams("fl")); - if (params.getParams("sort") == null) { + if (params.getParams(SORT) == null) { throw new IOException("sort param expected for search function"); } - String sorts = String.join(",", params.getParams("sort")); + String sorts = String.join(",", params.getParams(SORT)); this.comp = parseComp(sorts, fls); } @@ -403,7 +406,7 @@ public class CloudSolrStream extends TupleStream implements Expressible { Collection slices = CloudSolrStream.getSlices(this.collection, zkStateReader, true); ModifiableSolrParams mParams = new ModifiableSolrParams(params); - mParams.set("distrib", "false"); // We are the aggregator. + mParams.set(DISTRIB, "false"); // We are the aggregator. Set liveNodes = clusterState.getLiveNodes(); for(Slice slice : slices) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FeaturesSelectionStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FeaturesSelectionStream.java index f15e2a7c530..c5339cbcf0d 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FeaturesSelectionStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FeaturesSelectionStream.java @@ -59,6 +59,7 @@ import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SolrjNamedThreadFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.ID; public class FeaturesSelectionStream extends TupleStream implements Expressible{ @@ -415,7 +416,7 @@ public class FeaturesSelectionStream extends TupleStream implements Expressible{ ModifiableSolrParams params = new ModifiableSolrParams(); HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl); - params.add("distrib", "false"); + params.add(DISTRIB, "false"); params.add("fq","{!igain}"); for(String key : paramsMap.keySet()) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FetchStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FetchStream.java index 55ca51a8277..06e6fdcced7 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FetchStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FetchStream.java @@ -37,6 +37,7 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue; import org.apache.solr.client.solrj.io.stream.expr.StreamFactory; import org.apache.solr.common.params.ModifiableSolrParams; +import static org.apache.solr.common.params.CommonParams.SORT; import static org.apache.solr.common.params.CommonParams.VERSION_FIELD; /** @@ -238,7 +239,7 @@ public class FetchStream extends TupleStream implements Expressible { params.add("q", buf.toString()); params.add("fl", fieldList+appendFields()); params.add("rows", Integer.toString(batchSize)); - params.add("sort", "_version_ desc"); + params.add(SORT, "_version_ desc"); CloudSolrStream cloudSolrStream = new CloudSolrStream(zkHost, collection, params); StreamContext newContext = new StreamContext(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java index 0f951038b19..172b9ef7994 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/JDBCStream.java @@ -45,6 +45,8 @@ import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter; import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue; import org.apache.solr.client.solrj.io.stream.expr.StreamFactory; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * Connects to a datasource using a registered JDBC driver and execute a query. The results of * that query will be returned as tuples. An EOF tuple will indicate that all have been read. @@ -104,7 +106,7 @@ public class JDBCStream extends TupleStream implements Expressible { List namedParams = factory.getNamedOperands(expression); StreamExpressionNamedParameter connectionUrlExpression = factory.getNamedOperand(expression, "connection"); StreamExpressionNamedParameter sqlQueryExpression = factory.getNamedOperand(expression, "sql"); - StreamExpressionNamedParameter definedSortExpression = factory.getNamedOperand(expression, "sort"); + StreamExpressionNamedParameter definedSortExpression = factory.getNamedOperand(expression, SORT); StreamExpressionNamedParameter driverClassNameExpression = factory.getNamedOperand(expression, "driver"); // Validate there are no unknown parameters - zkHost and alias are namedParameter so we don't need to count it twice @@ -115,7 +117,7 @@ public class JDBCStream extends TupleStream implements Expressible { // All named params we don't care about will be passed to the driver on connection Properties connectionProperties = new Properties(); for(StreamExpressionNamedParameter namedParam : namedParams){ - if(!namedParam.getName().equals("driver") && !namedParam.getName().equals("connection") && !namedParam.getName().equals("sql") && !namedParam.getName().equals("sort")){ + if(!namedParam.getName().equals("driver") && !namedParam.getName().equals("connection") && !namedParam.getName().equals("sql") && !namedParam.getName().equals(SORT)){ connectionProperties.put(namedParam.getName(), namedParam.getParameter().toString().trim()); } } @@ -367,7 +369,7 @@ public class JDBCStream extends TupleStream implements Expressible { expression.addParameter(new StreamExpressionNamedParameter("sql", sqlQuery)); // sort - expression.addParameter(new StreamExpressionNamedParameter("sort", definedSort.toExpression(factory))); + expression.addParameter(new StreamExpressionNamedParameter(SORT, definedSort.toExpression(factory))); // driver class if(null != driverClassName){ diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ParallelStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ParallelStream.java index 10e80ad4273..87e13549d05 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ParallelStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ParallelStream.java @@ -21,23 +21,23 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Set; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Random; +import java.util.Set; import org.apache.solr.client.solrj.io.Tuple; import org.apache.solr.client.solrj.io.comp.FieldComparator; import org.apache.solr.client.solrj.io.comp.StreamComparator; import org.apache.solr.client.solrj.io.stream.expr.Explanation; +import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType; import org.apache.solr.client.solrj.io.stream.expr.Expressible; import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation; import org.apache.solr.client.solrj.io.stream.expr.StreamExpression; import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionNamedParameter; import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue; import org.apache.solr.client.solrj.io.stream.expr.StreamFactory; -import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType; import org.apache.solr.common.cloud.ClusterState; import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; @@ -45,6 +45,9 @@ import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.params.ModifiableSolrParams; +import static org.apache.solr.common.params.CommonParams.DISTRIB; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * The ParallelStream decorates a TupleStream implementation and pushes it to N workers for parallel execution. * Workers are chosen from a SolrCloud collection. @@ -85,7 +88,7 @@ public class ParallelStream extends CloudSolrStream implements Expressible { String collectionName = factory.getValueOperand(expression, 0); StreamExpressionNamedParameter workersParam = factory.getNamedOperand(expression, "workers"); List streamExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, TupleStream.class); - StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, "sort"); + StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, SORT); StreamExpressionNamedParameter zkHostExpression = factory.getNamedOperand(expression, "zkHost"); // validate expression contains only what we want. @@ -188,7 +191,7 @@ public class ParallelStream extends CloudSolrStream implements Expressible { } // sort - expression.addParameter(new StreamExpressionNamedParameter("sort",comp.toExpression(factory))); + expression.addParameter(new StreamExpressionNamedParameter(SORT,comp.toExpression(factory))); // zkHost expression.addParameter(new StreamExpressionNamedParameter("zkHost", zkHost)); @@ -284,7 +287,7 @@ public class ParallelStream extends CloudSolrStream implements Expressible { for(int w=0; w streamExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, TupleStream.class); StreamExpressionNamedParameter nParam = factory.getNamedOperand(expression, "n"); - StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, "sort"); + StreamExpressionNamedParameter sortExpression = factory.getNamedOperand(expression, SORT); // validate expression contains only what we want. if(expression.getParameters().size() != streamExpressions.size() + 2){ @@ -129,7 +131,7 @@ public class RankStream extends TupleStream implements Expressible { } // sort - expression.addParameter(new StreamExpressionNamedParameter("sort",comp.toExpression(factory))); + expression.addParameter(new StreamExpressionNamedParameter(SORT, comp.toExpression(factory))); return expression; } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ScoreNodesStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ScoreNodesStream.java index f394424e7e1..177cee0433a 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ScoreNodesStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/ScoreNodesStream.java @@ -19,11 +19,11 @@ package org.apache.solr.client.solrj.io.stream; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.HashMap; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.io.SolrClientCache; @@ -42,6 +42,8 @@ import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.TermsParams; import org.apache.solr.common.util.NamedList; +import static org.apache.solr.common.params.CommonParams.DISTRIB; + /** * Iterates over a gatherNodes() expression and scores the Tuples based on tf-idf. * @@ -211,7 +213,7 @@ public class ScoreNodesStream extends TupleStream implements Expressible params.add(TermsParams.TERMS_STATS, "true"); params.add(TermsParams.TERMS_LIST, builder.toString()); params.add(TermsParams.TERMS_LIMIT, Integer.toString(nodes.size())); - params.add("distrib", "true"); + params.add(DISTRIB, "true"); QueryRequest request = new QueryRequest(params); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SignificantTermsStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SignificantTermsStream.java index 101a71d64d2..b4decd528ae 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SignificantTermsStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SignificantTermsStream.java @@ -49,6 +49,8 @@ import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SolrjNamedThreadFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; + public class SignificantTermsStream extends TupleStream implements Expressible{ private static final long serialVersionUID = 1; @@ -376,7 +378,7 @@ public class SignificantTermsStream extends TupleStream implements Expressible{ ModifiableSolrParams params = new ModifiableSolrParams(); HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl); - params.add("distrib", "false"); + params.add(DISTRIB, "false"); params.add("fq","{!sigificantTerms}"); for(String key : paramsMap.keySet()) { diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TextLogitStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TextLogitStream.java index 7f194f46776..5a70cedeb79 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TextLogitStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TextLogitStream.java @@ -60,6 +60,7 @@ import org.apache.solr.common.util.ExecutorUtil; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SolrjNamedThreadFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.ID; public class TextLogitStream extends TupleStream implements Expressible { @@ -615,7 +616,7 @@ public class TextLogitStream extends TupleStream implements Expressible { ModifiableSolrParams params = new ModifiableSolrParams(); HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl); - params.add("distrib", "false"); + params.add(DISTRIB, "false"); params.add("fq","{!tlogit}"); params.add("feature", feature); params.add("terms", TextLogitStream.toString(terms)); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TopicStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TopicStream.java index ccbe8c1673c..58063d0c6dd 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TopicStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/TopicStream.java @@ -63,7 +63,9 @@ import org.apache.solr.common.util.SolrjNamedThreadFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.solr.common.params.CommonParams.DISTRIB; import static org.apache.solr.common.params.CommonParams.ID; +import static org.apache.solr.common.params.CommonParams.SORT; import static org.apache.solr.common.params.CommonParams.VERSION_FIELD; public class TopicStream extends CloudSolrStream implements Expressible { @@ -436,8 +438,8 @@ public class TopicStream extends CloudSolrStream implements Expressible { long checkpoint = -1; ModifiableSolrParams params = new ModifiableSolrParams(); params.set("q","*:*"); - params.set("sort", "_version_ desc"); - params.set("distrib", "false"); + params.set(SORT, "_version_ desc"); + params.set(DISTRIB, "false"); params.set("rows", 1); for(Replica replica : replicas) { if(replica.getState() == Replica.State.ACTIVE && liveNodes.contains(replica.getNodeName())) { @@ -523,9 +525,9 @@ public class TopicStream extends CloudSolrStream implements Expressible { Collection slices = CloudSolrStream.getSlices(this.collection, zkStateReader, false); ModifiableSolrParams mParams = new ModifiableSolrParams(params); - mParams.set("distrib", "false"); // We are the aggregator. + mParams.set(DISTRIB, "false"); // We are the aggregator. String fl = mParams.get("fl"); - mParams.set("sort", "_version_ asc"); + mParams.set(SORT, "_version_ asc"); if(!fl.contains(VERSION_FIELD)) { fl += ",_version_"; } diff --git a/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java b/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java index d719500d096..497584667d2 100644 --- a/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java +++ b/solr/solrj/src/java/org/apache/solr/common/params/TermsParams.java @@ -18,6 +18,8 @@ package org.apache.solr.common.params; import java.util.regex.Pattern; +import static org.apache.solr.common.params.CommonParams.SORT; + /** * * @@ -112,20 +114,20 @@ public interface TermsParams { /** * Optional. The maximum value of docFreq to be returned. -1 by default means no boundary */ - public static final String TERMS_MAXCOUNT = TERMS_PREFIX + "maxcount"; + String TERMS_MAXCOUNT = TERMS_PREFIX + "maxcount"; /** * Optional. If true, return the raw characters of the indexed term, regardless of if it is readable. * For instance, the index form of numeric numbers is not human readable. The default is false. */ - public static final String TERMS_RAW = TERMS_PREFIX + "raw"; + String TERMS_RAW = TERMS_PREFIX + "raw"; /** * Optional. If sorting by frequency is enabled. Defaults to sorting by count. */ - public static final String TERMS_SORT = TERMS_PREFIX + "sort"; + String TERMS_SORT = TERMS_PREFIX + SORT; - public static final String TERMS_SORT_COUNT = "count"; - public static final String TERMS_SORT_INDEX = "index"; + String TERMS_SORT_COUNT = "count"; + String TERMS_SORT_INDEX = "index"; }