mirror of https://github.com/apache/lucene.git
SOLR-8565: add & use CommonParams.(ROWS|START)_DEFAULT constants, add CommonParamsTest
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1725708 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eae126ac1c
commit
16c53a0fea
solr
CHANGES.txt
core/src/java/org/apache/solr
solrj/src
java/org/apache/solr/common/params
test/org/apache/solr/common/params
|
@ -556,6 +556,8 @@ Other Changes
|
|||
* SOLR-8566: various initialCapacity tweaks (Fix Versions: trunk 5.5)
|
||||
(Christine Poerschke)
|
||||
|
||||
* SOLR-8565: add & use CommonParams.(ROWS|START)_DEFAULT constants (Christine Poerschke)
|
||||
|
||||
================== 5.4.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -166,8 +166,8 @@ public class MoreLikeThisHandler extends RequestHandlerBase
|
|||
}
|
||||
}
|
||||
|
||||
int start = params.getInt(CommonParams.START, 0);
|
||||
int rows = params.getInt(CommonParams.ROWS, 10);
|
||||
int start = params.getInt(CommonParams.START, CommonParams.START_DEFAULT);
|
||||
int rows = params.getInt(CommonParams.ROWS, CommonParams.ROWS_DEFAULT);
|
||||
|
||||
// Find documents MoreLikeThis - either with a reader or a query
|
||||
// --------------------------------------------------------------------------------
|
||||
|
|
|
@ -241,8 +241,8 @@ public abstract class QParser {
|
|||
}
|
||||
}
|
||||
|
||||
int start = startS != null ? Integer.parseInt(startS) : 0;
|
||||
int rows = rowsS != null ? Integer.parseInt(rowsS) : 10;
|
||||
int start = startS != null ? Integer.parseInt(startS) : CommonParams.START_DEFAULT;
|
||||
int rows = rowsS != null ? Integer.parseInt(rowsS) : CommonParams.ROWS_DEFAULT;
|
||||
|
||||
SortSpec sort = SortSpecParsing.parseSortSpec(sortStr, req);
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ public class ReRankQParserPlugin extends QParserPlugin {
|
|||
|
||||
double reRankWeight = localParams.getDouble("reRankWeight",2.0d);
|
||||
|
||||
int start = params.getInt(CommonParams.START,0);
|
||||
int rows = params.getInt(CommonParams.ROWS,10);
|
||||
int start = params.getInt(CommonParams.START,CommonParams.START_DEFAULT);
|
||||
int rows = params.getInt(CommonParams.ROWS,CommonParams.ROWS_DEFAULT);
|
||||
int length = start+rows;
|
||||
return new ReRankQuery(reRankQuery, reRankDocs, reRankWeight, length);
|
||||
}
|
||||
|
|
|
@ -62,9 +62,11 @@ public interface CommonParams {
|
|||
|
||||
/** zero based offset of matching documents to retrieve */
|
||||
public static final String START ="start";
|
||||
public static final int START_DEFAULT = 0;
|
||||
|
||||
/** number of documents to return starting at "start" */
|
||||
public static final String ROWS ="rows";
|
||||
public static final int ROWS_DEFAULT = 10;
|
||||
|
||||
// SOLR-4228 start
|
||||
/** handler value for SolrPing */
|
||||
|
|
|
@ -63,7 +63,7 @@ public interface TermsParams {
|
|||
public static final String TERMS_LOWER_INCLUSIVE = TERMS_PREFIX + "lower.incl";
|
||||
|
||||
/**
|
||||
* Optional. The number of results to return. If not specified, looks for {@link org.apache.solr.common.params.CommonParams#ROWS}. If that's not specified, uses 10.
|
||||
* Optional. The number of results to return. If not specified, looks for {@link org.apache.solr.common.params.CommonParams#ROWS}. If that's not specified, uses {@link org.apache.solr.common.params.CommonParams#ROWS_DEFAULT}.
|
||||
*/
|
||||
public static final String TERMS_LIMIT = TERMS_PREFIX + "limit";
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.common.params;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
||||
/**
|
||||
* Unit test for {@link CommonParams}
|
||||
*
|
||||
* This class tests backwards compatibility of CommonParams parameter constants.
|
||||
* If someone accidentally changes those constants then this test will flag that up.
|
||||
*/
|
||||
public class CommonParamsTest extends LuceneTestCase
|
||||
{
|
||||
public void testStart() { assertEquals(CommonParams.START, "start"); }
|
||||
public void testStartDefault() { assertEquals(CommonParams.START_DEFAULT, 0); }
|
||||
|
||||
public void testRows() { assertEquals(CommonParams.ROWS, "rows"); }
|
||||
public void testRowsDefault() { assertEquals(CommonParams.ROWS_DEFAULT, 10); }
|
||||
}
|
Loading…
Reference in New Issue