You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2011/12/15 06:11:30 UTC
svn commit: r1214623 [14/17] - in /lucene/dev/branches/solrcloud: ./
dev-tools/idea/lucene/contrib/ lucene/ lucene/contrib/
lucene/contrib/demo/src/java/org/apache/lucene/demo/
lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighligh...
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.queries.functi
*/
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -39,7 +39,7 @@ public abstract class MultiFloatFunction
}
abstract protected String name();
- abstract protected float func(int doc, DocValues[] valsArr);
+ abstract protected float func(int doc, FunctionValues[] valsArr);
@Override
public String description() {
@@ -59,8 +59,8 @@ public abstract class MultiFloatFunction
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues[] valsArr = new DocValues[sources.length];
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final FunctionValues[] valsArr = new FunctionValues[sources.length];
for (int i=0; i<sources.length; i++) {
valsArr[i] = sources[i].getValues(context, readerContext);
}
@@ -75,7 +75,7 @@ public abstract class MultiFloatFunction
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(');
boolean firstTime=true;
- for (DocValues vals : valsArr) {
+ for (FunctionValues vals : valsArr) {
if (firstTime) {
firstTime=false;
} else {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/MultiFunction.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.queries.functi
*/
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.util.BytesRef;
@@ -58,8 +58,8 @@ public abstract class MultiFunction exte
return sb.toString();
}
- public static DocValues[] valsArr(List<ValueSource> sources, Map fcontext, AtomicReaderContext readerContext) throws IOException {
- final DocValues[] valsArr = new DocValues[sources.size()];
+ public static FunctionValues[] valsArr(List<ValueSource> sources, Map fcontext, AtomicReaderContext readerContext) throws IOException {
+ final FunctionValues[] valsArr = new FunctionValues[sources.size()];
int i=0;
for (ValueSource source : sources) {
valsArr[i++] = source.getValues(fcontext, readerContext);
@@ -67,10 +67,10 @@ public abstract class MultiFunction exte
return valsArr;
}
- public class Values extends DocValues {
- final DocValues[] valsArr;
+ public class Values extends FunctionValues {
+ final FunctionValues[] valsArr;
- public Values(DocValues[] valsArr) {
+ public Values(FunctionValues[] valsArr) {
this.valsArr = valsArr;
}
@@ -87,11 +87,11 @@ public abstract class MultiFunction exte
}
- public static String toString(String name, DocValues[] valsArr, int doc) {
+ public static String toString(String name, FunctionValues[] valsArr, int doc) {
StringBuilder sb = new StringBuilder();
sb.append(name).append('(');
boolean firstTime=true;
- for (DocValues vals : valsArr) {
+ for (FunctionValues vals : valsArr) {
if (firstTime) {
firstTime=false;
} else {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NormValueSource.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -49,7 +49,7 @@ public class NormValueSource extends Val
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
IndexSearcher searcher = (IndexSearcher)context.get("searcher");
Similarity sim = searcher.getSimilarityProvider().get(field);
if (!(sim instanceof TFIDFSimilarity)) {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumDocsValueSource.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.util.ReaderUtil;
@@ -35,7 +35,7 @@ public class NumDocsValueSource extends
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
// Searcher has no numdocs so we must use the reader instead
return new ConstIntDocValues(ReaderUtil.getTopLevelContext(readerContext).reader.numDocs(), this);
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumericIndexDocValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumericIndexDocValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumericIndexDocValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/NumericIndexDocValueSource.java Thu Dec 15 05:11:14 2011
@@ -19,16 +19,16 @@ package org.apache.lucene.queries.functi
import java.io.IOException;
import java.util.Map;
+import org.apache.lucene.index.DocValues.Source;
+import org.apache.lucene.index.DocValues.Type;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.index.values.IndexDocValues;
-import org.apache.lucene.index.values.ValueType;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
/**
- * Expert: obtains numeric field values from a {@link IndexDocValues} field.
+ * Expert: obtains numeric field values from a {@link FunctionValues} field.
* This {@link ValueSource} is compatible with all numerical
- * {@link IndexDocValues}
+ * {@link FunctionValues}
*
* @lucene.experimental
*
@@ -42,15 +42,15 @@ public class NumericIndexDocValueSource
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final IndexDocValues.Source source = readerContext.reader.docValues(field)
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final Source source = readerContext.reader.docValues(field)
.getSource();
- ValueType type = source.type();
+ Type type = source.type();
switch (type) {
case FLOAT_32:
case FLOAT_64:
// TODO (chrism) Change to use FloatDocValues and IntDocValues
- return new DocValues() {
+ return new FunctionValues() {
@Override
public String toString(int doc) {
@@ -64,7 +64,7 @@ public class NumericIndexDocValueSource
};
case VAR_INTS:
- return new DocValues() {
+ return new FunctionValues() {
@Override
public String toString(int doc) {
return "float: [" + floatVal(doc) + "]";
@@ -113,6 +113,6 @@ public class NumericIndexDocValueSource
@Override
public String toString() {
- return "DocValues float(" + field + ')';
+ return "FunctionValues float(" + field + ')';
}
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/OrdFieldSource.java Thu Dec 15 05:11:14 2011
@@ -19,7 +19,7 @@ package org.apache.lucene.queries.functi
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.IntDocValues;
import org.apache.lucene.search.FieldCache;
@@ -62,7 +62,7 @@ public class OrdFieldSource extends Valu
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final int off = readerContext.docBase;
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader;
final FieldCache.DocTermsIndex sindex = FieldCache.DEFAULT.getTermsIndex(topReader, field);
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/PowFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/PowFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/PowFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/PowFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@
package org.apache.lucene.queries.function.valuesource;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
/** Function to raise the base "a" to the power "b"
@@ -37,7 +37,7 @@ public class PowFloatFunction extends Du
}
@Override
- protected float func(int doc, DocValues aVals, DocValues bVals) {
+ protected float func(int doc, FunctionValues aVals, FunctionValues bVals) {
return (float)Math.pow(aVals.floatVal(doc), bVals.floatVal(doc));
}
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ProductFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ProductFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ProductFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ProductFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@
package org.apache.lucene.queries.function.valuesource;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
/**
@@ -34,9 +34,9 @@ public class ProductFloatFunction extend
}
@Override
- protected float func(int doc, DocValues[] valsArr) {
+ protected float func(int doc, FunctionValues[] valsArr) {
float val = 1.0f;
- for (DocValues vals : valsArr) {
+ for (FunctionValues vals : valsArr) {
val *= vals.floatVal(doc);
}
return val;
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.*;
@@ -51,7 +51,7 @@ public class QueryValueSource extends Va
}
@Override
- public DocValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map fcontext, AtomicReaderContext readerContext) throws IOException {
return new QueryDocValues(this, readerContext, fcontext);
}
@@ -193,8 +193,8 @@ class QueryDocValues extends FloatDocVal
public ValueFiller getValueFiller() {
//
// TODO: if we want to support more than one value-filler or a value-filler in conjunction with
- // the DocValues, then members like "scorer" should be per ValueFiller instance.
- // Or we can say that the user should just instantiate multiple DocValues.
+ // the FunctionValues, then members like "scorer" should be per ValueFiller instance.
+ // Or we can say that the user should just instantiate multiple FunctionValues.
//
return new ValueFiller() {
private final MutableValueFloat mval = new MutableValueFloat();
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/RangeMapFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/RangeMapFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/RangeMapFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/RangeMapFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -55,8 +55,8 @@ public class RangeMapFloatFunction exten
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues vals = source.getValues(context, readerContext);
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final FunctionValues vals = source.getValues(context, readerContext);
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReciprocalFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReciprocalFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReciprocalFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReciprocalFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -61,8 +61,8 @@ public class ReciprocalFloatFunction ext
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues vals = source.getValues(context, readerContext);
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final FunctionValues vals = source.getValues(context, readerContext);
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ReverseOrdFieldSource.java Thu Dec 15 05:11:14 2011
@@ -19,7 +19,7 @@ package org.apache.lucene.queries.functi
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.IntDocValues;
import org.apache.lucene.search.FieldCache;
@@ -62,7 +62,7 @@ public class ReverseOrdFieldSource exten
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final IndexReader topReader = ReaderUtil.getTopLevelContext(readerContext).reader;
final int off = readerContext.docBase;
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ScaleFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -67,7 +67,7 @@ public class ScaleFloatFunction extends
for (AtomicReaderContext leaf : leaves) {
int maxDoc = leaf.reader.maxDoc();
- DocValues vals = source.getValues(context, leaf);
+ FunctionValues vals = source.getValues(context, leaf);
for (int i=0; i<maxDoc; i++) {
float val = vals.floatVal(i);
@@ -98,7 +98,7 @@ public class ScaleFloatFunction extends
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
ScaleInfo scaleInfo = (ScaleInfo)context.get(source);
if (scaleInfo == null) {
@@ -109,7 +109,7 @@ public class ScaleFloatFunction extends
final float minSource = scaleInfo.minVal;
final float maxSource = scaleInfo.maxVal;
- final DocValues vals = source.getValues(context, readerContext);
+ final FunctionValues vals = source.getValues(context, readerContext);
return new FloatDocValues(this) {
@Override
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ShortFieldSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ShortFieldSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ShortFieldSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/ShortFieldSource.java Thu Dec 15 05:11:14 2011
@@ -20,7 +20,7 @@ import java.io.IOException;
import java.util.Map;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.search.FieldCache;
@@ -47,10 +47,10 @@ public class ShortFieldSource extends Fi
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
final short[] arr = cache.getShorts(readerContext.reader, field, parser, false);
- return new DocValues() {
+ return new FunctionValues() {
@Override
public byte byteVal(int doc) {
return (byte) arr[doc];
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleBoolFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleBoolFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleBoolFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleBoolFunction.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.BoolDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -36,11 +36,11 @@ public abstract class SimpleBoolFunction
protected abstract String name();
- protected abstract boolean func(int doc, DocValues vals);
+ protected abstract boolean func(int doc, FunctionValues vals);
@Override
public BoolDocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues vals = source.getValues(context, readerContext);
+ final FunctionValues vals = source.getValues(context, readerContext);
return new BoolDocValues(this) {
@Override
public boolean boolVal(int doc) {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SimpleFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
@@ -32,11 +32,11 @@ import java.util.Map;
super(source);
}
- protected abstract float func(int doc, DocValues vals);
+ protected abstract float func(int doc, FunctionValues vals);
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
- final DocValues vals = source.getValues(context, readerContext);
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ final FunctionValues vals = source.getValues(context, readerContext);
return new FloatDocValues(this) {
@Override
public float floatVal(int doc) {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumFloatFunction.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumFloatFunction.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumFloatFunction.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumFloatFunction.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@
package org.apache.lucene.queries.function.valuesource;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
/**
@@ -34,9 +34,9 @@ public class SumFloatFunction extends Mu
}
@Override
- protected float func(int doc, DocValues[] valsArr) {
+ protected float func(int doc, FunctionValues[] valsArr) {
float val = 0.0f;
- for (DocValues vals : valsArr) {
+ for (FunctionValues vals : valsArr) {
val += vals.floatVal(doc);
}
return val;
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumTotalTermFreqValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumTotalTermFreqValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumTotalTermFreqValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/SumTotalTermFreqValueSource.java Thu Dec 15 05:11:14 2011
@@ -20,7 +20,7 @@ package org.apache.lucene.queries.functi
import org.apache.lucene.index.Fields;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Terms;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.LongDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -50,8 +50,8 @@ public class SumTotalTermFreqValueSource
}
@Override
- public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
- return (DocValues)context.get(this);
+ public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
+ return (FunctionValues)context.get(this);
}
@Override
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java Thu Dec 15 05:11:14 2011
@@ -19,7 +19,7 @@ package org.apache.lucene.queries.functi
import org.apache.lucene.index.*;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.docvalues.FloatDocValues;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
@@ -41,7 +41,7 @@ public class TFValueSource extends TermF
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
Fields fields = readerContext.reader.fields();
final Terms terms = fields.terms(field);
final Similarity sim = ((IndexSearcher)context.get("searcher")).getSimilarityProvider().get(field);
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java Thu Dec 15 05:11:14 2011
@@ -19,7 +19,7 @@ package org.apache.lucene.queries.functi
import org.apache.lucene.index.*;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.docvalues.IntDocValues;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.util.BytesRef;
@@ -38,7 +38,7 @@ public class TermFreqValueSource extends
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
Fields fields = readerContext.reader.fields();
final Terms terms = fields.terms(field);
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TotalTermFreqValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TotalTermFreqValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TotalTermFreqValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/TotalTermFreqValueSource.java Thu Dec 15 05:11:14 2011
@@ -18,7 +18,7 @@
package org.apache.lucene.queries.function.valuesource;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.LongDocValues;
import org.apache.lucene.search.IndexSearcher;
@@ -54,8 +54,8 @@ public class TotalTermFreqValueSource ex
}
@Override
- public DocValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
- return (DocValues)context.get(this);
+ public FunctionValues getValues(Map context, IndexReader.AtomicReaderContext readerContext) throws IOException {
+ return (FunctionValues)context.get(this);
}
@Override
Modified: lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/VectorValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/VectorValueSource.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/VectorValueSource.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/java/org/apache/lucene/queries/function/valuesource/VectorValueSource.java Thu Dec 15 05:11:14 2011
@@ -17,7 +17,7 @@ package org.apache.lucene.queries.functi
*/
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
-import org.apache.lucene.queries.function.DocValues;
+import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.search.IndexSearcher;
@@ -27,8 +27,8 @@ import java.util.Map;
/**
- * Converts individual ValueSource instances to leverage the DocValues *Val functions that work with multiple values,
- * i.e. {@link org.apache.lucene.queries.function.DocValues#doubleVal(int, double[])}
+ * Converts individual ValueSource instances to leverage the FunctionValues *Val functions that work with multiple values,
+ * i.e. {@link org.apache.lucene.queries.function.FunctionValues#doubleVal(int, double[])}
*/
//Not crazy about the name, but...
public class VectorValueSource extends MultiValueSource {
@@ -53,14 +53,14 @@ public class VectorValueSource extends M
}
@Override
- public DocValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
+ public FunctionValues getValues(Map context, AtomicReaderContext readerContext) throws IOException {
int size = sources.size();
// special-case x,y and lat,lon since it's so common
if (size==2) {
- final DocValues x = sources.get(0).getValues(context, readerContext);
- final DocValues y = sources.get(1).getValues(context, readerContext);
- return new DocValues() {
+ final FunctionValues x = sources.get(0).getValues(context, readerContext);
+ final FunctionValues y = sources.get(1).getValues(context, readerContext);
+ return new FunctionValues() {
@Override
public void byteVal(int doc, byte[] vals) {
vals[0] = x.byteVal(doc);
@@ -105,12 +105,12 @@ public class VectorValueSource extends M
}
- final DocValues[] valsArr = new DocValues[size];
+ final FunctionValues[] valsArr = new FunctionValues[size];
for (int i = 0; i < size; i++) {
valsArr[i] = sources.get(i).getValues(context, readerContext);
}
- return new DocValues() {
+ return new FunctionValues() {
@Override
public void byteVal(int doc, byte[] vals) {
for (int i = 0; i < valsArr.length; i++) {
@@ -165,7 +165,7 @@ public class VectorValueSource extends M
StringBuilder sb = new StringBuilder();
sb.append(name()).append('(');
boolean firstTime = true;
- for (DocValues vals : valsArr) {
+ for (FunctionValues vals : valsArr) {
if (firstTime) {
firstTime = false;
} else {
Modified: lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/ChainedFilterTest.java Thu Dec 15 05:11:14 2011
@@ -94,7 +94,6 @@ public class ChainedFilterTest extends L
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
directory.close();
super.tearDown();
@@ -211,7 +210,6 @@ public class ChainedFilterTest extends L
// throws java.lang.ClassCastException: org.apache.lucene.util.OpenBitSet cannot be cast to java.util.BitSet
searcher.search(new MatchAllDocsQuery(), cf, 1);
- searcher.close();
reader.close();
dir.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/TestCustomScoreQuery.java Thu Dec 15 05:11:14 2011
@@ -208,7 +208,6 @@ public class TestCustomScoreQuery extend
final float score = hits.scoreDocs[i].score;
assertEquals("doc=" + doc, (float) 1+(4*doc) % N_DOCS, score, 0.0001);
}
- s.close();
r.close();
}
@@ -232,7 +231,6 @@ public class TestCustomScoreQuery extend
assertEquals(s.search(q,1).totalHits, s.search(original,1).totalHits);
assertEquals(s.search(q,1).totalHits, s.search(rewritten,1).totalHits);
- s.close();
r.close();
}
@@ -290,7 +288,6 @@ public class TestCustomScoreQuery extend
verifyResults(boost, s,
h1, h2CustomNeutral, h3CustomMul, h4CustomAdd, h5CustomMulAdd,
q1, q2CustomNeutral, q3CustomMul, q4CustomAdd, q5CustomMulAdd);
- s.close();
r.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestFieldScoreQuery.java Thu Dec 15 05:11:14 2011
@@ -95,7 +95,6 @@ public class TestFieldScoreQuery extends
assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
prevID = resID;
}
- s.close();
r.close();
}
@@ -143,7 +142,6 @@ public class TestFieldScoreQuery extends
float expectedScore = expectedFieldScore(id); // "ID7" --> 7.0
assertEquals("score of " + id + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
}
- s.close();
r.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/function/TestOrdValues.java Thu Dec 15 05:11:14 2011
@@ -92,7 +92,6 @@ public class TestOrdValues extends Funct
}
prevID = resID;
}
- s.close();
r.close();
}
@@ -139,7 +138,6 @@ public class TestOrdValues extends Funct
: id2String(i + 1); // reverse ==> smaller values first
assertTrue("id of result " + i + " shuould be " + expectedId + " != " + score, expectedId.equals(id));
}
- s.close();
r.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java (original)
+++ lucene/dev/branches/solrcloud/modules/queries/src/test/org/apache/lucene/queries/mlt/TestMoreLikeThis.java Thu Dec 15 05:11:14 2011
@@ -59,7 +59,6 @@ public class TestMoreLikeThis extends Lu
@Override
public void tearDown() throws Exception {
reader.close();
- searcher.close();
directory.close();
super.tearDown();
}
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/classic/TestMultiFieldQueryParser.java Thu Dec 15 05:11:14 2011
@@ -295,7 +295,6 @@ public class TestMultiFieldQueryParser e
IndexSearcher is = new IndexSearcher(ir);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
assertEquals(1, hits.length);
- is.close();
ir.close();
ramDir.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/complexPhrase/TestComplexPhraseQuery.java Thu Dec 15 05:11:14 2011
@@ -128,7 +128,6 @@ public class TestComplexPhraseQuery exte
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
rd.close();
super.tearDown();
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestMultiFieldQPHelper.java Thu Dec 15 05:11:14 2011
@@ -333,7 +333,6 @@ public class TestMultiFieldQPHelper exte
IndexSearcher is = new IndexSearcher(ir);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
assertEquals(1, hits.length);
- is.close();
ir.close();
ramDir.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java Thu Dec 15 05:11:14 2011
@@ -488,7 +488,6 @@ public class TestNumericQueryParser exte
@AfterClass
public static void afterClass() throws Exception {
- searcher.close();
searcher = null;
reader.close();
reader = null;
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestQPHelper.java Thu Dec 15 05:11:14 2011
@@ -1269,7 +1269,6 @@ public class TestQPHelper extends Lucene
Query q = new StandardQueryParser(new CannedAnalyzer()).parse("\"a\"", "field");
assertTrue(q instanceof MultiPhraseQuery);
assertEquals(1, s.search(q, 10).totalHits);
- s.close();
r.close();
w.close();
dir.close();
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTst.java Thu Dec 15 05:11:14 2011
@@ -127,7 +127,6 @@ public class BooleanQueryTst {
try {
searcher.search(query, tc);
} finally {
- searcher.close();
reader.close();
}
tc.checkNrHits();
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/util/QueryParserTestBase.java Thu Dec 15 05:11:14 2011
@@ -1095,7 +1095,6 @@ public abstract class QueryParserTestBas
QueryParser qp = new QueryParser(TEST_VERSION_CURRENT, "f", a);
Query q = qp.parse("\"wizard of ozzy\"");
assertEquals(1, s.search(q, 1).totalHits);
- s.close();
r.close();
dir.close();
}
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestParser.java Thu Dec 15 05:11:14 2011
@@ -76,7 +76,7 @@ public class TestParser extends LuceneTe
}
d.close();
writer.close();
- reader = IndexReader.open(dir, true);
+ reader = IndexReader.open(dir);
searcher = newSearcher(reader);
}
@@ -84,7 +84,6 @@ public class TestParser extends LuceneTe
@AfterClass
public static void afterClass() throws Exception {
reader.close();
- searcher.close();
dir.close();
reader = null;
searcher = null;
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/TestQueryTemplateManager.java Thu Dec 15 05:11:14 2011
@@ -159,7 +159,6 @@ public class TestQueryTemplateManager ex
@Override
public void tearDown() throws Exception {
- searcher.close();
reader.close();
dir.close();
super.tearDown();
Modified: lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java (original)
+++ lucene/dev/branches/solrcloud/modules/queryparser/src/test/org/apache/lucene/queryparser/xml/builders/TestNumericRangeFilterBuilder.java Thu Dec 15 05:11:14 2011
@@ -63,7 +63,7 @@ public class TestNumericRangeFilterBuild
IndexWriter writer = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
writer.commit();
try {
- IndexReader reader = new SlowMultiReaderWrapper(IndexReader.open(ramDir, true));
+ IndexReader reader = new SlowMultiReaderWrapper(IndexReader.open(ramDir));
try {
assertNull(filter.getDocIdSet((AtomicReaderContext) reader.getTopReaderContext(), reader.getLiveDocs()));
}
Modified: lucene/dev/branches/solrcloud/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java (original)
+++ lucene/dev/branches/solrcloud/modules/suggest/src/java/org/apache/lucene/search/spell/SpellChecker.java Thu Dec 15 05:11:14 2011
@@ -639,7 +639,6 @@ public class SpellChecker implements jav
closed = true;
if (searcher != null) {
searcher.getIndexReader().close();
- searcher.close();
}
searcher = null;
}
@@ -655,12 +654,10 @@ public class SpellChecker implements jav
synchronized (searcherLock) {
if(closed){
indexSearcher.getIndexReader().close();
- indexSearcher.close();
throw new AlreadyClosedException("Spellchecker has been closed");
}
if (searcher != null) {
searcher.getIndexReader().close();
- searcher.close();
}
// set the spellindex in the sync block - ensure consistency.
searcher = indexSearcher;
Modified: lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java (original)
+++ lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java Thu Dec 15 05:11:14 2011
@@ -84,7 +84,7 @@ public class TestLuceneDictionary extend
public void testFieldNonExistent() throws IOException {
try {
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
ld = new LuceneDictionary(indexReader, "nonexistent_field");
it = ld.getWordsIterator();
@@ -98,7 +98,7 @@ public class TestLuceneDictionary extend
public void testFieldAaa() throws IOException {
try {
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
ld = new LuceneDictionary(indexReader, "aaa");
it = ld.getWordsIterator();
@@ -114,7 +114,7 @@ public class TestLuceneDictionary extend
public void testFieldContents_1() throws IOException {
try {
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
ld = new LuceneDictionary(indexReader, "contents");
it = ld.getWordsIterator();
@@ -144,7 +144,7 @@ public class TestLuceneDictionary extend
public void testFieldContents_2() throws IOException {
try {
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
ld = new LuceneDictionary(indexReader, "contents");
it = ld.getWordsIterator();
@@ -176,7 +176,7 @@ public class TestLuceneDictionary extend
public void testFieldZzz() throws IOException {
try {
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
ld = new LuceneDictionary(indexReader, "zzz");
it = ld.getWordsIterator();
@@ -194,7 +194,7 @@ public class TestLuceneDictionary extend
public void testSpellchecker() throws IOException {
Directory dir = newDirectory();
SpellChecker sc = new SpellChecker(dir);
- indexReader = IndexReader.open(store, true);
+ indexReader = IndexReader.open(store);
sc.indexDictionary(new LuceneDictionary(indexReader, "contents"), newIndexWriterConfig(TEST_VERSION_CURRENT, null), false);
String[] suggestions = sc.suggestSimilar("Tam", 1);
assertEquals(1, suggestions.length);
Modified: lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java (original)
+++ lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/spell/TestSpellChecker.java Thu Dec 15 05:11:14 2011
@@ -104,7 +104,7 @@ public class TestSpellChecker extends Lu
public void testBuild() throws CorruptIndexException, IOException {
- IndexReader r = IndexReader.open(userindex, true);
+ IndexReader r = IndexReader.open(userindex);
spellChecker.clearIndex();
@@ -144,7 +144,7 @@ public class TestSpellChecker extends Lu
}
public void testComparator() throws Exception {
- IndexReader r = IndexReader.open(userindex, true);
+ IndexReader r = IndexReader.open(userindex);
Directory compIdx = newDirectory();
SpellChecker compareSP = new SpellCheckerMock(compIdx, new LevensteinDistance(), new SuggestWordFrequencyComparator());
addwords(r, compareSP, "field3");
@@ -162,7 +162,7 @@ public class TestSpellChecker extends Lu
}
public void testBogusField() throws Exception {
- IndexReader r = IndexReader.open(userindex, true);
+ IndexReader r = IndexReader.open(userindex);
Directory compIdx = newDirectory();
SpellChecker compareSP = new SpellCheckerMock(compIdx, new LevensteinDistance(), new SuggestWordFrequencyComparator());
addwords(r, compareSP, "field3");
@@ -177,7 +177,7 @@ public class TestSpellChecker extends Lu
}
public void testSuggestModes() throws Exception {
- IndexReader r = IndexReader.open(userindex, true);
+ IndexReader r = IndexReader.open(userindex);
spellChecker.clearIndex();
addwords(r, spellChecker, "field1");
@@ -337,7 +337,7 @@ public class TestSpellChecker extends Lu
}
private int numdoc() throws IOException {
- IndexReader rs = IndexReader.open(spellindex, true);
+ IndexReader rs = IndexReader.open(spellindex);
int num = rs.numDocs();
assertTrue(num != 0);
//System.out.println("num docs: " + num);
@@ -346,7 +346,7 @@ public class TestSpellChecker extends Lu
}
public void testClose() throws IOException {
- IndexReader r = IndexReader.open(userindex, true);
+ IndexReader r = IndexReader.open(userindex);
spellChecker.clearIndex();
String field = "field1";
addwords(r, spellChecker, "field1");
@@ -402,7 +402,7 @@ public class TestSpellChecker extends Lu
*/
public void testConcurrentAccess() throws IOException, InterruptedException {
assertEquals(1, searchers.size());
- final IndexReader r = IndexReader.open(userindex, true);
+ final IndexReader r = IndexReader.open(userindex);
spellChecker.clearIndex();
assertEquals(2, searchers.size());
addwords(r, spellChecker, "field1");
Modified: lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FloatMagicTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FloatMagicTest.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FloatMagicTest.java (original)
+++ lucene/dev/branches/solrcloud/modules/suggest/src/test/org/apache/lucene/search/suggest/fst/FloatMagicTest.java Thu Dec 15 05:11:14 2011
@@ -9,7 +9,7 @@ import org.junit.Test;
public class FloatMagicTest extends LuceneTestCase {
public void testFloatMagic() {
- ArrayList<Float> floats = new ArrayList<Float>(Arrays.asList(new Float [] {
+ ArrayList<Float> floats = new ArrayList<Float>(Arrays.asList(
Float.intBitsToFloat(0x7f800001), // NaN (invalid combination).
Float.intBitsToFloat(0x7fffffff), // NaN (invalid combination).
Float.intBitsToFloat(0xff800001), // NaN (invalid combination).
@@ -26,7 +26,7 @@ public class FloatMagicTest extends Luce
-0.1f,
-1f,
-10f,
- Float.NEGATIVE_INFINITY }));
+ Float.NEGATIVE_INFINITY));
// Sort them using juc.
Collections.sort(floats);
Modified: lucene/dev/branches/solrcloud/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/CHANGES.txt?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/CHANGES.txt (original)
+++ lucene/dev/branches/solrcloud/solr/CHANGES.txt Thu Dec 15 05:11:14 2011
@@ -195,6 +195,8 @@ New Features
"multiterm" analyzer in our schema.xml, but Solr should "do the right thing" if you don't
specify <fieldType="multiterm"> (Pete Sturge Erick Erickson, Mentoring from Seeley and Muir)
+* SOLR-2481: Add support for commitWithin in DataImportHandler (Sami Siren via yonik)
+
Optimizations
----------------------
@@ -292,6 +294,8 @@ Bug Fixes
* SOLR-1730: Made it clearer when a core failed to load as well as better logging when the
QueryElevationComponent fails to properly initialize (gsingers)
+* SOLR-1520: QueryElevationComponent now supports non-string ids (gsingers)
+
Other Changes
----------------------
@@ -409,6 +413,7 @@ New Features
* SOLR-2919: Added support for localized range queries when the analysis chain uses
CollationKeyFilter or ICUCollationKeyFilter. (Michael Sokolov, rmuir)
+
Bug Fixes
----------------------
* SOLR-2912: Fixed File descriptor leak in ShowFileRequestHandler (Michael Ryan, shalin)
@@ -418,11 +423,21 @@ Bug Fixes
* SOLR-2509: StringIndexOutOfBoundsException in the spellchecker collate when the term contains
a hyphen. (Thomas Gambier caught the bug, Steffen Godskesen did the patch, via Erick Erickson)
+
+* SOLR-2955: Fixed IllegalStateException when querying with group.sort=score desc in sharded
+ environment. (Steffen Elberg Godskesen, Martijn van Groningen)
+
+* SOLR-2956: Fixed inconsistencies in the flags (and flag key) reported by
+ the LukeRequestHandler (hossman)
Other Changes
----------------------
* SOLR-2922: Upgrade commons-io and commons-lang to 2.1 and 2.6, respectively. (koji)
+* SOLR-2920: Refactor frequent conditional use of DefaultSolrParams and
+ AppendedSolrParams into factory methods.
+ (David Smiley via hossman)
+
================== 3.5.0 ==================
New Features
Modified: lucene/dev/branches/solrcloud/solr/NOTICE.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/NOTICE.txt?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/NOTICE.txt (original)
+++ lucene/dev/branches/solrcloud/solr/NOTICE.txt Thu Dec 15 05:11:14 2011
@@ -64,8 +64,8 @@ Jean-Philippe Barrette-LaPierre. This li
see http://sites.google.com/site/rrettesite/moman and
http://bitbucket.org/jpbarrette/moman/overview/
-The class org.apache.lucene.SorterTemplate was inspired by CGLIB's class with
-the same name. The implementation part is mainly done using pre-existing
+The class org.apache.lucene.util.SorterTemplate was inspired by CGLIB's class
+with the same name. The implementation part is mainly done using pre-existing
Lucene sorting code. In-place stable mergesort was borrowed from CGLIB,
which is Apache-licensed.
Modified: lucene/dev/branches/solrcloud/solr/contrib/clustering/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/contrib/clustering/CHANGES.txt?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/contrib/clustering/CHANGES.txt (original)
+++ lucene/dev/branches/solrcloud/solr/contrib/clustering/CHANGES.txt Thu Dec 15 05:11:14 2011
@@ -13,7 +13,27 @@ $Id$
================== Release 3.6.0 ==================
-(No Changes)
+* SOLR-2937: Configuring the number of contextual snippets used for
+ search results clustering. The hl.snippets parameter is now respected
+ by the clustering plugin, can be overridden by carrot.summarySnippets
+ if needed (Stanislaw Osinski).
+
+* SOLR-2938: Clustering on multiple fields. The carrot.title and
+ carrot.snippet can now take comma- or space-separated lists of
+ field names to cluster (Stanislaw Osinski).
+
+* SOLR-2939: Clustering of multilingual search results. The document's
+ language field be passed in the carrot.lang parameter, the carrot.lcmap
+ parameter enables mapping of language codes to ISO 639 (Stanislaw Osinski).
+
+* SOLR-2940: Passing values for custom Carrot2 fields. The custom field
+ mapping are defined using the carrot.custom parameter (Stanislaw Osinski).
+
+* SOLR-2941: NullPointerException on clustering component initialization
+ when schema does not have a unique key field (Stanislaw Osinski).
+
+* SOLR-2942: ClassCastException when passing non-textual fields for
+ clustering (Stanislaw Osinski).
================== Release 3.5.0 ==================
@@ -21,10 +41,10 @@ $Id$
================== Release 3.4.0 ==================
-SOLR-2706: The carrot.lexicalResourcesDir parameter now works
- with absolute directories (Stanislaw Osinski)
+* SOLR-2706: The carrot.lexicalResourcesDir parameter now works
+ with absolute directories (Stanislaw Osinski)
-SOLR-2692: Typo in param name fixed: "carrot.fragzise" changed to
+* SOLR-2692: Typo in param name fixed: "carrot.fragzise" changed to
"carrot.fragSize" (Stanislaw Osinski).
================== Release 3.3.0 ==================
Modified: lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java (original)
+++ lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotClusteringEngine.java Thu Dec 15 05:11:14 2011
@@ -19,15 +19,18 @@ package org.apache.solr.handler.clusteri
import java.io.*;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrDocument;
@@ -45,6 +48,7 @@ import org.apache.solr.handler.component
import org.apache.solr.highlight.SolrHighlighter;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.DocList;
import org.apache.solr.search.DocSlice;
import org.apache.solr.search.SolrIndexSearcher;
@@ -54,6 +58,7 @@ import org.carrot2.core.Controller;
import org.carrot2.core.ControllerFactory;
import org.carrot2.core.Document;
import org.carrot2.core.IClusteringAlgorithm;
+import org.carrot2.core.LanguageCode;
import org.carrot2.core.attribute.AttributeNames;
import org.carrot2.text.linguistic.DefaultLexicalDataFactoryDescriptor;
import org.carrot2.text.preprocessing.pipeline.BasicPreprocessingPipelineDescriptor;
@@ -77,13 +82,13 @@ import com.google.common.io.Closeables;
* @see "http://project.carrot2.org"
*/
public class CarrotClusteringEngine extends SearchClusteringEngine {
- private transient static Logger log = LoggerFactory
+ private transient static Logger log = LoggerFactory
.getLogger(CarrotClusteringEngine.class);
- /**
- * The subdirectory in Solr config dir to read customized Carrot2 resources from.
- */
- private static final String CARROT_RESOURCES_PREFIX = "clustering/carrot2";
+ /**
+ * The subdirectory in Solr config dir to read customized Carrot2 resources from.
+ */
+ private static final String CARROT_RESOURCES_PREFIX = "clustering/carrot2";
/**
* Name of Carrot2 document's field containing Solr document's identifier.
@@ -102,7 +107,7 @@ public class CarrotClusteringEngine exte
*/
private Controller controller = ControllerFactory.createPooling();
private Class<? extends IClusteringAlgorithm> clusteringAlgorithmClass;
-
+
private static class SolrResourceLocator implements IResourceLocator {
private final SolrResourceLoader resourceLoader;
private final String carrot2ResourcesDir;
@@ -227,8 +232,8 @@ public class CarrotClusteringEngine exte
}
}
- @Override
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public String init(NamedList config, final SolrCore core) {
String result = super.init(config, core);
final SolrParams initParams = SolrParams.toSolrParams(config);
@@ -243,13 +248,13 @@ public class CarrotClusteringEngine exte
// Additionally, we set a custom lexical resource factory for Carrot2 that
// will use both Carrot2 default stop words as well as stop words from
// the StopFilter defined on the field.
- BasicPreprocessingPipelineDescriptor.attributeBuilder(initAttributes)
- .stemmerFactory(LuceneCarrot2StemmerFactory.class)
- .tokenizerFactory(LuceneCarrot2TokenizerFactory.class)
- .lexicalDataFactory(SolrStopwordsCarrot2LexicalDataFactory.class);
+ BasicPreprocessingPipelineDescriptor.attributeBuilder(initAttributes)
+ .stemmerFactory(LuceneCarrot2StemmerFactory.class)
+ .tokenizerFactory(LuceneCarrot2TokenizerFactory.class)
+ .lexicalDataFactory(SolrStopwordsCarrot2LexicalDataFactory.class);
- // Pass the schema to SolrStopwordsCarrot2LexicalDataFactory.
- initAttributes.put("solrIndexSchema", core.getSchema());
+ // Pass the schema to SolrStopwordsCarrot2LexicalDataFactory.
+ initAttributes.put("solrIndexSchema", core.getSchema());
// Customize Carrot2's resource lookup to first look for resources
// using Solr's resource loader. If that fails, try loading from the classpath.
@@ -261,7 +266,13 @@ public class CarrotClusteringEngine exte
new ClassLoaderLocator(core.getResourceLoader().getClassLoader())));
this.controller.init(initAttributes);
- this.idFieldName = core.getSchema().getUniqueKeyField().getName();
+
+ SchemaField uniqueField = core.getSchema().getUniqueKeyField();
+ if (uniqueField == null) {
+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+ CarrotClusteringEngine.class.getSimpleName() + " requires the schema to have a uniqueKeyField");
+ }
+ this.idFieldName = uniqueField.getName();
// Make sure the requested Carrot2 clustering algorithm class is available
String carrotAlgorithmClassName = initParams.get(CarrotParams.ALGORITHM);
@@ -283,25 +294,35 @@ public class CarrotClusteringEngine exte
HashSet<String> fields = Sets.newHashSet(getFieldsForClustering(sreq));
fields.add(idFieldName);
fields.add(solrParams.get(CarrotParams.URL_FIELD_NAME, "url"));
- return fields;
+ fields.addAll(getCustomFieldsMap(solrParams).keySet());
+
+ String languageField = solrParams.get(CarrotParams.LANGUAGE_FIELD_NAME);
+ if (StringUtils.isNotBlank(languageField)) {
+ fields.add(languageField);
+ }
+ return fields;
}
- /**
- * Returns the names of fields that will be delivering the actual
- * content for clustering. Currently, there are two such fields: document
- * title and document content.
- */
- private Set<String> getFieldsForClustering(SolrQueryRequest sreq) {
+ /**
+ * Returns the names of fields that will be delivering the actual
+ * content for clustering. Currently, there are two such fields: document
+ * title and document content.
+ */
+ private Set<String> getFieldsForClustering(SolrQueryRequest sreq) {
SolrParams solrParams = sreq.getParams();
- String titleField = solrParams.get(CarrotParams.TITLE_FIELD_NAME, "title");
- String snippetField = solrParams.get(CarrotParams.SNIPPET_FIELD_NAME, titleField);
- if (StringUtils.isBlank(snippetField)) {
+ String titleFieldSpec = solrParams.get(CarrotParams.TITLE_FIELD_NAME, "title");
+ String snippetFieldSpec = solrParams.get(CarrotParams.SNIPPET_FIELD_NAME, titleFieldSpec);
+ if (StringUtils.isBlank(snippetFieldSpec)) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, CarrotParams.SNIPPET_FIELD_NAME
+ " must not be blank.");
}
- return Sets.newHashSet(titleField, snippetField);
- }
+
+ final Set<String> fields = Sets.newHashSet();
+ fields.addAll(Arrays.asList(titleFieldSpec.split("[, ]")));
+ fields.addAll(Arrays.asList(snippetFieldSpec.split("[, ]")));
+ return fields;
+ }
/**
* Prepares Carrot2 documents for clustering.
@@ -313,8 +334,27 @@ public class CarrotClusteringEngine exte
SolrCore core = sreq.getCore();
String urlField = solrParams.get(CarrotParams.URL_FIELD_NAME, "url");
- String titleField = solrParams.get(CarrotParams.TITLE_FIELD_NAME, "title");
- String snippetField = solrParams.get(CarrotParams.SNIPPET_FIELD_NAME, titleField);
+ String titleFieldSpec = solrParams.get(CarrotParams.TITLE_FIELD_NAME, "title");
+ String snippetFieldSpec = solrParams.get(CarrotParams.SNIPPET_FIELD_NAME, titleFieldSpec);
+ String languageField = solrParams.get(CarrotParams.LANGUAGE_FIELD_NAME, null);
+
+ // Maps Solr field names to Carrot2 custom field names
+ Map<String, String> customFields = getCustomFieldsMap(solrParams);
+
+ // Parse language code map string into a map
+ Map<String, String> languageCodeMap = Maps.newHashMap();
+ if (StringUtils.isNotBlank(languageField)) {
+ for (String pair : solrParams.get(CarrotParams.LANGUAGE_CODE_MAP, "")
+ .split("[, ]")) {
+ final String[] split = pair.split(":");
+ if (split.length == 2 && StringUtils.isNotBlank(split[0]) && StringUtils.isNotBlank(split[1])) {
+ languageCodeMap.put(split[0], split[1]);
+ } else {
+ log.warn("Unsupported format for " + CarrotParams.LANGUAGE_CODE_MAP
+ + ": '" + pair + "'. Skipping this mapping.");
+ }
+ }
+ }
// Get the documents
boolean produceSummary = solrParams.getBool(CarrotParams.PRODUCE_SUMMARY, false);
@@ -325,12 +365,13 @@ public class CarrotClusteringEngine exte
highlighter = HighlightComponent.getHighlighter(core);
if (highlighter != null){
Map<String, Object> args = Maps.newHashMap();
- snippetFieldAry = new String[]{snippetField};
+ snippetFieldAry = snippetFieldSpec.split("[, ]");
args.put(HighlightParams.FIELDS, snippetFieldAry);
args.put(HighlightParams.HIGHLIGHT, "true");
args.put(HighlightParams.SIMPLE_PRE, ""); //we don't care about actually highlighting the area
args.put(HighlightParams.SIMPLE_POST, "");
args.put(HighlightParams.FRAGSIZE, solrParams.getInt(CarrotParams.SUMMARY_FRAGSIZE, solrParams.getInt(HighlightParams.FRAGSIZE, 100)));
+ args.put(HighlightParams.SNIPPETS, solrParams.getInt(CarrotParams.SUMMARY_SNIPPETS, solrParams.getInt(HighlightParams.SNIPPETS, 1)));
req = new LocalSolrQueryRequest(core, query.toString(), "", 0, 1, args) {
@Override
public SolrIndexSearcher getSearcher() {
@@ -352,7 +393,8 @@ public class CarrotClusteringEngine exte
while (docsIter.hasNext()) {
SolrDocument sdoc = docsIter.next();
- String snippet = getValue(sdoc, snippetField);
+ String snippet = null;
+
// TODO: docIds will be null when running distributed search.
// See comment in ClusteringComponent#finishStage().
if (produceSummary && docIds != null) {
@@ -360,34 +402,115 @@ public class CarrotClusteringEngine exte
DocList docAsList = new DocSlice(0, 1, docsHolder, scores, 1, 1.0f);
NamedList<Object> highlights = highlighter.doHighlighting(docAsList, theQuery, req, snippetFieldAry);
if (highlights != null && highlights.size() == 1) {//should only be one value given our setup
- //should only be one document with one field
+ //should only be one document
@SuppressWarnings("unchecked")
- NamedList<String []> tmp = (NamedList<String[]>) highlights.getVal(0);
- String [] highlt = tmp.get(snippetField);
- if (highlt != null && highlt.length == 1) {
- snippet = highlt[0];
+ NamedList<String []> tmp = (NamedList<String[]>) highlights.getVal(0);
+
+ final StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < snippetFieldAry.length; j++) {
+ // Join fragments with a period, so that Carrot2 does not create
+ // cross-fragment phrases, such phrases rarely make sense.
+ String [] highlt = tmp.get(snippetFieldAry[j]);
+ if (highlt != null && highlt.length > 0) {
+ for (int i = 0; i < highlt.length; i++) {
+ sb.append(highlt[i]);
+ sb.append(" . ");
+ }
+ }
}
+ snippet = sb.toString();
}
}
- Document carrotDocument = new Document(getValue(sdoc, titleField),
- snippet, (String)sdoc.getFieldValue(urlField));
+
+ // If summaries not enabled or summary generation failed, use full content.
+ if (snippet == null) {
+ snippet = getConcatenated(sdoc, snippetFieldSpec);
+ }
+
+ // Create a Carrot2 document
+ Document carrotDocument = new Document(getConcatenated(sdoc, titleFieldSpec),
+ snippet, ObjectUtils.toString(sdoc.getFieldValue(urlField), ""));
+
+ // Store Solr id of the document, we need it to map document instances
+ // found in clusters back to identifiers.
carrotDocument.setField(SOLR_DOCUMENT_ID, sdoc.getFieldValue(idFieldName));
+
+ // Set language
+ if (StringUtils.isNotBlank(languageField)) {
+ Collection<Object> languages = sdoc.getFieldValues(languageField);
+ if (languages != null) {
+
+ // Use the first Carrot2-supported language
+ for (Object l : languages) {
+ String lang = ObjectUtils.toString(l, "");
+
+ if (languageCodeMap.containsKey(lang)) {
+ lang = languageCodeMap.get(lang);
+ }
+
+ // Language detection Library for Java uses dashes to separate
+ // language variants, such as 'zh-cn', but Carrot2 uses underscores.
+ if (lang.indexOf('-') > 0) {
+ lang = lang.replace('-', '_');
+ }
+
+ // If the language is supported by Carrot2, we'll get a non-null value
+ final LanguageCode carrot2Language = LanguageCode.forISOCode(lang);
+ if (carrot2Language != null) {
+ carrotDocument.setLanguage(carrot2Language);
+ break;
+ }
+ }
+ }
+ }
+
+ // Add custom fields
+ if (customFields != null) {
+ for (Entry<String, String> entry : customFields.entrySet()) {
+ carrotDocument.setField(entry.getValue(), sdoc.getFieldValue(entry.getKey()));
+ }
+ }
+
result.add(carrotDocument);
}
return result;
}
- protected String getValue(SolrDocument sdoc, String field) {
+ /**
+ * Prepares a map of Solr field names (keys) to the corresponding Carrot2
+ * custom field names.
+ */
+ private Map<String, String> getCustomFieldsMap(SolrParams solrParams) {
+ Map<String, String> customFields = Maps.newHashMap();
+ String [] customFieldsSpec = solrParams.getParams(CarrotParams.CUSTOM_FIELD_NAME);
+ if (customFieldsSpec != null) {
+ customFields = Maps.newHashMap();
+ for (String customFieldSpec : customFieldsSpec) {
+ String [] split = customFieldSpec.split(":");
+ if (split.length == 2 && StringUtils.isNotBlank(split[0]) && StringUtils.isNotBlank(split[1])) {
+ customFields.put(split[0], split[1]);
+ } else {
+ log.warn("Unsupported format for " + CarrotParams.CUSTOM_FIELD_NAME
+ + ": '" + customFieldSpec + "'. Skipping this field definition.");
+ }
+ }
+ }
+ return customFields;
+ }
+
+ private String getConcatenated(SolrDocument sdoc, String fieldsSpec) {
StringBuilder result = new StringBuilder();
- Collection<Object> vals = sdoc.getFieldValues(field);
- if(vals == null) return "";
- Iterator<Object> ite = vals.iterator();
- while(ite.hasNext()){
- // Join multiple values with a period so that Carrot2 does not pick up
- // phrases that cross field value boundaries (in most cases it would
- // create useless phrases).
- result.append((String)ite.next()).append(" . ");
+ for (String field : fieldsSpec.split("[, ]")) {
+ Collection<Object> vals = sdoc.getFieldValues(field);
+ if (vals == null) continue;
+ Iterator<Object> ite = vals.iterator();
+ while(ite.hasNext()){
+ // Join multiple values with a period so that Carrot2 does not pick up
+ // phrases that cross field value boundaries (in most cases it would
+ // create useless phrases).
+ result.append(ObjectUtils.toString(ite.next())).append(" . ");
+ }
}
return result.toString().trim();
}
Modified: lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotParams.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotParams.java?rev=1214623&r1=1214622&r2=1214623&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotParams.java (original)
+++ lucene/dev/branches/solrcloud/solr/contrib/clustering/src/java/org/apache/solr/handler/clustering/carrot2/CarrotParams.java Thu Dec 15 05:11:14 2011
@@ -27,17 +27,24 @@ public interface CarrotParams {
String CARROT_PREFIX = "carrot.";
String ALGORITHM = CARROT_PREFIX + "algorithm";
+
String TITLE_FIELD_NAME = CARROT_PREFIX + "title";
String URL_FIELD_NAME = CARROT_PREFIX + "url";
String SNIPPET_FIELD_NAME = CARROT_PREFIX + "snippet";
+ String LANGUAGE_FIELD_NAME = CARROT_PREFIX + "lang";
+ String CUSTOM_FIELD_NAME = CARROT_PREFIX + "custom";
+
String PRODUCE_SUMMARY = CARROT_PREFIX + "produceSummary";
- String NUM_DESCRIPTIONS = CARROT_PREFIX + "numDescriptions";
- String OUTPUT_SUB_CLUSTERS = CARROT_PREFIX + "outputSubClusters";
String SUMMARY_FRAGSIZE = CARROT_PREFIX + "fragSize";
+ String SUMMARY_SNIPPETS = CARROT_PREFIX + "summarySnippets";
+ String NUM_DESCRIPTIONS = CARROT_PREFIX + "numDescriptions";
+ String OUTPUT_SUB_CLUSTERS = CARROT_PREFIX + "outputSubClusters";
String LEXICAL_RESOURCES_DIR = CARROT_PREFIX + "lexicalResourcesDir";
+ String LANGUAGE_CODE_MAP = CARROT_PREFIX + "lcmap";
public static final Set<String> CARROT_PARAM_NAMES = ImmutableSet.of(
- ALGORITHM, TITLE_FIELD_NAME, URL_FIELD_NAME, SNIPPET_FIELD_NAME,
- PRODUCE_SUMMARY, NUM_DESCRIPTIONS, OUTPUT_SUB_CLUSTERS, SUMMARY_FRAGSIZE);
+ ALGORITHM, TITLE_FIELD_NAME, URL_FIELD_NAME, SNIPPET_FIELD_NAME, LANGUAGE_FIELD_NAME,
+ PRODUCE_SUMMARY, SUMMARY_FRAGSIZE, SUMMARY_SNIPPETS, NUM_DESCRIPTIONS, OUTPUT_SUB_CLUSTERS,
+ LEXICAL_RESOURCES_DIR);
}