You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/01/12 19:55:32 UTC
svn commit: r1230702 [2/2] - in /lucene/dev/branches/lucene3305: ./
dev-tools/idea/lucene/contrib/ lucene/
lucene/contrib/highlighter/src/java/org/apache/lucene/search/vectorhighlight/
lucene/contrib/memory/src/java/org/apache/lucene/index/memory/ luce...
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestIndexReader.java Thu Jan 12 18:55:30 2012
@@ -36,7 +36,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexReader.FieldOption;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldCache;
@@ -46,6 +45,7 @@ import org.apache.lucene.store.NoSuchDir
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util._TestUtil;
import org.junit.Assume;
@@ -102,11 +102,11 @@ public class TestIndexReader extends Luc
writer.close();
// set up reader
IndexReader reader = IndexReader.open(d);
- Collection<String> fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unstored"));
+ FieldInfos fieldInfos = ReaderUtil.getMergedFieldInfos(reader);
+ assertNotNull(fieldInfos.fieldInfo("keyword"));
+ assertNotNull(fieldInfos.fieldInfo("text"));
+ assertNotNull(fieldInfos.fieldInfo("unindexed"));
+ assertNotNull(fieldInfos.fieldInfo("unstored"));
reader.close();
// add more documents
writer = new IndexWriter(
@@ -160,61 +160,66 @@ public class TestIndexReader extends Luc
}
writer.close();
+
// verify fields again
reader = IndexReader.open(d);
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertEquals(13, fieldNames.size()); // the following fields
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unstored"));
- assertTrue(fieldNames.contains("keyword2"));
- assertTrue(fieldNames.contains("text2"));
- assertTrue(fieldNames.contains("unindexed2"));
- assertTrue(fieldNames.contains("unstored2"));
- assertTrue(fieldNames.contains("tvnot"));
- assertTrue(fieldNames.contains("termvector"));
- assertTrue(fieldNames.contains("tvposition"));
- assertTrue(fieldNames.contains("tvoffset"));
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ fieldInfos = ReaderUtil.getMergedFieldInfos(reader);
+
+ Collection<String> allFieldNames = new HashSet<String>();
+ Collection<String> indexedFieldNames = new HashSet<String>();
+ Collection<String> notIndexedFieldNames = new HashSet<String>();
+ Collection<String> tvFieldNames = new HashSet<String>();
+
+ for(FieldInfo fieldInfo : fieldInfos) {
+ final String name = fieldInfo.name;
+ allFieldNames.add(name);
+ if (fieldInfo.isIndexed) {
+ indexedFieldNames.add(name);
+ } else {
+ notIndexedFieldNames.add(name);
+ }
+ if (fieldInfo.storeTermVector) {
+ tvFieldNames.add(name);
+ }
+ }
+
+ assertTrue(allFieldNames.contains("keyword"));
+ assertTrue(allFieldNames.contains("text"));
+ assertTrue(allFieldNames.contains("unindexed"));
+ assertTrue(allFieldNames.contains("unstored"));
+ assertTrue(allFieldNames.contains("keyword2"));
+ assertTrue(allFieldNames.contains("text2"));
+ assertTrue(allFieldNames.contains("unindexed2"));
+ assertTrue(allFieldNames.contains("unstored2"));
+ assertTrue(allFieldNames.contains("tvnot"));
+ assertTrue(allFieldNames.contains("termvector"));
+ assertTrue(allFieldNames.contains("tvposition"));
+ assertTrue(allFieldNames.contains("tvoffset"));
+ assertTrue(allFieldNames.contains("tvpositionoffset"));
// verify that only indexed fields were returned
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.INDEXED);
- assertEquals(11, fieldNames.size()); // 6 original + the 5 termvector fields
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unstored"));
- assertTrue(fieldNames.contains("keyword2"));
- assertTrue(fieldNames.contains("text2"));
- assertTrue(fieldNames.contains("unstored2"));
- assertTrue(fieldNames.contains("tvnot"));
- assertTrue(fieldNames.contains("termvector"));
- assertTrue(fieldNames.contains("tvposition"));
- assertTrue(fieldNames.contains("tvoffset"));
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ assertEquals(11, indexedFieldNames.size()); // 6 original + the 5 termvector fields
+ assertTrue(indexedFieldNames.contains("keyword"));
+ assertTrue(indexedFieldNames.contains("text"));
+ assertTrue(indexedFieldNames.contains("unstored"));
+ assertTrue(indexedFieldNames.contains("keyword2"));
+ assertTrue(indexedFieldNames.contains("text2"));
+ assertTrue(indexedFieldNames.contains("unstored2"));
+ assertTrue(indexedFieldNames.contains("tvnot"));
+ assertTrue(indexedFieldNames.contains("termvector"));
+ assertTrue(indexedFieldNames.contains("tvposition"));
+ assertTrue(indexedFieldNames.contains("tvoffset"));
+ assertTrue(indexedFieldNames.contains("tvpositionoffset"));
// verify that only unindexed fields were returned
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.UNINDEXED);
- assertEquals(2, fieldNames.size()); // the following fields
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unindexed2"));
+ assertEquals(2, notIndexedFieldNames.size()); // the following fields
+ assertTrue(notIndexedFieldNames.contains("unindexed"));
+ assertTrue(notIndexedFieldNames.contains("unindexed2"));
// verify index term vector fields
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR);
- assertEquals(1, fieldNames.size()); // 1 field has term vector only
- assertTrue(fieldNames.contains("termvector"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvposition"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_OFFSET);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvoffset"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION_OFFSET);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ assertEquals(tvFieldNames.toString(), 4, tvFieldNames.size()); // 4 field has term vector only
+ assertTrue(tvFieldNames.contains("termvector"));
+
reader.close();
d.close();
}
@@ -519,19 +524,19 @@ public class TestIndexReader extends Luc
}
// check field names
- Collection<String> fields1 = index1.getFieldNames(FieldOption.ALL);
- Collection<String> fields2 = index1.getFieldNames(FieldOption.ALL);
- assertEquals("IndexReaders have different numbers of fields.", fields1.size(), fields2.size());
- Iterator<String> it1 = fields1.iterator();
- Iterator<String> it2 = fields1.iterator();
- while (it1.hasNext()) {
- assertEquals("Different field names.", it1.next(), it2.next());
+ FieldInfos fieldInfos1 = ReaderUtil.getMergedFieldInfos(index1);
+ FieldInfos fieldInfos2 = ReaderUtil.getMergedFieldInfos(index2);
+ assertEquals("IndexReaders have different numbers of fields.", fieldInfos1.size(), fieldInfos2.size());
+ final int numFields = fieldInfos1.size();
+ for(int fieldID=0;fieldID<numFields;fieldID++) {
+ final FieldInfo fieldInfo1 = fieldInfos1.fieldInfo(fieldID);
+ final FieldInfo fieldInfo2 = fieldInfos2.fieldInfo(fieldID);
+ assertEquals("Different field names.", fieldInfo1.name, fieldInfo2.name);
}
// check norms
- it1 = fields1.iterator();
- while (it1.hasNext()) {
- String curField = it1.next();
+ for(FieldInfo fieldInfo : fieldInfos1) {
+ String curField = fieldInfo.name;
DocValues norms1 = MultiDocValues.getNormDocValues(index1, curField);
DocValues norms2 = MultiDocValues.getNormDocValues(index2, curField);
if (norms1 != null && norms2 != null)
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java Thu Jan 12 18:55:30 2012
@@ -67,7 +67,7 @@ public class TestOmitNorms extends Lucen
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitNorms);
assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
@@ -121,7 +121,7 @@ public class TestOmitNorms extends Lucen
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f1").omitNorms);
assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
@@ -169,7 +169,7 @@ public class TestOmitNorms extends Lucen
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertTrue("OmitNorms field bit should not be set.", !fi.fieldInfo("f1").omitNorms);
assertTrue("OmitNorms field bit should be set.", fi.fieldInfo("f2").omitNorms);
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitPositions.java Thu Jan 12 18:55:30 2012
@@ -154,7 +154,7 @@ public class TestOmitPositions extends L
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
// docs + docs = docs
assertEquals(IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
// docs + docs/freqs = docs
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitTf.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestOmitTf.java Thu Jan 12 18:55:30 2012
@@ -101,7 +101,7 @@ public class TestOmitTf extends LuceneTe
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
@@ -153,7 +153,7 @@ public class TestOmitTf extends LuceneTe
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f1").indexOptions);
assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
@@ -196,7 +196,7 @@ public class TestOmitTf extends LuceneTe
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertEquals("OmitTermFreqAndPositions field bit should not be set.", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").indexOptions);
assertEquals("OmitTermFreqAndPositions field bit should be set.", IndexOptions.DOCS_ONLY, fi.fieldInfo("f2").indexOptions);
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestParallelReader.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestParallelReader.java Thu Jan 12 18:55:30 2012
@@ -18,14 +18,12 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Collection;
import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.TextField;
import org.apache.lucene.search.BooleanClause.Occur;
-import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@@ -75,12 +73,12 @@ public class TestParallelReader extends
ParallelReader pr = new ParallelReader();
pr.add(IndexReader.open(dir1));
pr.add(IndexReader.open(dir2));
- Collection<String> fieldNames = pr.getFieldNames(IndexReader.FieldOption.ALL);
- assertEquals(4, fieldNames.size());
- assertTrue(fieldNames.contains("f1"));
- assertTrue(fieldNames.contains("f2"));
- assertTrue(fieldNames.contains("f3"));
- assertTrue(fieldNames.contains("f4"));
+ FieldInfos fieldInfos = pr.getFieldInfos();
+ assertEquals(4, fieldInfos.size());
+ assertNotNull(fieldInfos.fieldInfo("f1"));
+ assertNotNull(fieldInfos.fieldInfo("f2"));
+ assertNotNull(fieldInfos.fieldInfo("f3"));
+ assertNotNull(fieldInfos.fieldInfo("f4"));
pr.close();
dir1.close();
dir2.close();
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestPayloads.java Thu Jan 12 18:55:30 2012
@@ -112,7 +112,7 @@ public class TestPayloads extends Lucene
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f3").storePayloads);
@@ -139,7 +139,7 @@ public class TestPayloads extends Lucene
writer.close();
reader = getOnlySegmentReader(IndexReader.open(ram));
- fi = reader.fieldInfos();
+ fi = reader.getFieldInfos();
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f3").storePayloads);
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java Thu Jan 12 18:55:30 2012
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Collection;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
@@ -30,6 +29,7 @@ import org.apache.lucene.util.InfoStream
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
+
public class TestSegmentMerger extends LuceneTestCase {
//The variables for the new merged segment
private Directory mergedDir;
@@ -107,10 +107,15 @@ public class TestSegmentMerger extends L
assertTrue(termDocs != null);
assertTrue(termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
- Collection<String> stored = mergedReader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
- assertTrue(stored != null);
+ int tvCount = 0;
+ for(FieldInfo fieldInfo : mergedReader.getFieldInfos()) {
+ if (fieldInfo.storeTermVector) {
+ tvCount++;
+ }
+ }
+
//System.out.println("stored size: " + stored.size());
- assertTrue("We do not have 3 fields that were indexed with term vector",stored.size() == 3);
+ assertEquals("We do not have 3 fields that were indexed with term vector", 3, tvCount);
Terms vector = mergedReader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
assertNotNull(vector);
Modified: lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/dev/branches/lucene3305/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java Thu Jan 12 18:55:30 2012
@@ -19,7 +19,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Collection;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.List;
import org.apache.lucene.document.Document;
@@ -74,33 +74,42 @@ public class TestSegmentReader extends L
}
public void testGetFieldNameVariations() {
- Collection<String> result = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.all.size());
- for (Iterator<String> iter = result.iterator(); iter.hasNext();) {
- String s = iter.next();
- //System.out.println("Name: " + s);
+ Collection<String> allFieldNames = new HashSet<String>();
+ Collection<String> indexedFieldNames = new HashSet<String>();
+ Collection<String> notIndexedFieldNames = new HashSet<String>();
+ Collection<String> tvFieldNames = new HashSet<String>();
+ Collection<String> noTVFieldNames = new HashSet<String>();
+
+ for(FieldInfo fieldInfo : reader.getFieldInfos()) {
+ final String name = fieldInfo.name;
+ allFieldNames.add(name);
+ if (fieldInfo.isIndexed) {
+ indexedFieldNames.add(name);
+ } else {
+ notIndexedFieldNames.add(name);
+ }
+ if (fieldInfo.storeTermVector) {
+ tvFieldNames.add(name);
+ } else if (fieldInfo.isIndexed) {
+ noTVFieldNames.add(name);
+ }
+ }
+
+ assertTrue(allFieldNames.size() == DocHelper.all.size());
+ for (String s : allFieldNames) {
assertTrue(DocHelper.nameValues.containsKey(s) == true || s.equals(""));
}
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.indexed.size());
- for (Iterator<String> iter = result.iterator(); iter.hasNext();) {
- String s = iter.next();
+
+ assertTrue(indexedFieldNames.size() == DocHelper.indexed.size());
+ for (String s : indexedFieldNames) {
assertTrue(DocHelper.indexed.containsKey(s) == true || s.equals(""));
}
- result = reader.getFieldNames(IndexReader.FieldOption.UNINDEXED);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.unindexed.size());
+ assertTrue(notIndexedFieldNames.size() == DocHelper.unindexed.size());
//Get all indexed fields that are storing term vectors
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.termvector.size());
-
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED_NO_TERMVECTOR);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.notermvector.size());
+ assertTrue(tvFieldNames.size() == DocHelper.termvector.size());
+
+ assertTrue(noTVFieldNames.size() == DocHelper.notermvector.size());
}
public void testTerms() throws IOException {
Modified: lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilter.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilter.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/hunspell/HunspellStemFilter.java Thu Jan 12 18:55:30 2012
@@ -24,6 +24,7 @@ import org.apache.lucene.analysis.TokenF
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.hunspell.HunspellStemmer.Stem;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.analysis.tokenattributes.KeywordAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
/**
@@ -34,6 +35,7 @@ public final class HunspellStemFilter ex
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posIncAtt = addAttribute(PositionIncrementAttribute.class);
+ private final KeywordAttribute keywordAtt = addAttribute(KeywordAttribute.class);
private final HunspellStemmer stemmer;
private List<Stem> buffer;
@@ -84,6 +86,10 @@ public final class HunspellStemFilter ex
return false;
}
+ if (keywordAtt.isKeyword()) {
+ return true;
+ }
+
buffer = dedup ? stemmer.uniqueStems(termAtt.buffer(), termAtt.length()) : stemmer.stem(termAtt.buffer(), termAtt.length());
if (buffer.isEmpty()) { // we do not know this word, return it unchanged
Modified: lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java Thu Jan 12 18:55:30 2012
@@ -16,21 +16,22 @@ package org.apache.lucene.analysis.query
* limitations under the License.
*/
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.AnalyzerWrapper;
+import org.apache.lucene.analysis.core.StopFilter;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.core.StopFilter;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util.Version;
-import org.apache.lucene.util.BytesRef;
-
-import java.io.IOException;
-import java.util.*;
/**
* An {@link Analyzer} used primarily at query time to wrap another analyzer and provide a layer of protection
@@ -84,7 +85,7 @@ public final class QueryAutoStopWordAnal
Analyzer delegate,
IndexReader indexReader,
int maxDocFreq) throws IOException {
- this(matchVersion, delegate, indexReader, indexReader.getFieldNames(IndexReader.FieldOption.INDEXED), maxDocFreq);
+ this(matchVersion, delegate, indexReader, ReaderUtil.getIndexedFields(indexReader), maxDocFreq);
}
/**
@@ -104,7 +105,7 @@ public final class QueryAutoStopWordAnal
Analyzer delegate,
IndexReader indexReader,
float maxPercentDocs) throws IOException {
- this(matchVersion, delegate, indexReader, indexReader.getFieldNames(IndexReader.FieldOption.INDEXED), maxPercentDocs);
+ this(matchVersion, delegate, indexReader, ReaderUtil.getIndexedFields(indexReader), maxPercentDocs);
}
/**
Modified: lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellDictionaryTest.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellDictionaryTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellDictionaryTest.java Thu Jan 12 18:55:30 2012
@@ -1,6 +1,6 @@
package org.apache.lucene.analysis.hunspell;
-/*
+/**
* 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.
@@ -17,6 +17,7 @@ package org.apache.lucene.analysis.hunsp
* limitations under the License.
*/
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.Version;
import org.junit.Test;
@@ -26,14 +27,14 @@ import java.text.ParseException;
import static junit.framework.Assert.assertEquals;
-public class HunspellDictionaryTest {
+public class HunspellDictionaryTest extends LuceneTestCase {
@Test
public void testHunspellDictionary_loadDicAff() throws IOException, ParseException {
InputStream affixStream = getClass().getResourceAsStream("test.aff");
InputStream dictStream = getClass().getResourceAsStream("test.dic");
- HunspellDictionary dictionary = new HunspellDictionary(affixStream, dictStream, Version.LUCENE_40);
+ HunspellDictionary dictionary = new HunspellDictionary(affixStream, dictStream, TEST_VERSION_CURRENT);
assertEquals(3, dictionary.lookupSuffix(new char[]{'e'}, 0, 1).size());
assertEquals(1, dictionary.lookupPrefix(new char[]{'s'}, 0, 1).size());
assertEquals(1, dictionary.lookupWord(new char[]{'o', 'l', 'r'}, 0, 3).size());
Modified: lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java (original)
+++ lucene/dev/branches/lucene3305/modules/analysis/common/src/test/org/apache/lucene/analysis/hunspell/HunspellStemmerTest.java Thu Jan 12 18:55:30 2012
@@ -1,6 +1,6 @@
package org.apache.lucene.analysis.hunspell;
-/*
+/**
* 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.
@@ -17,6 +17,7 @@ package org.apache.lucene.analysis.hunsp
* limitations under the License.
*/
+import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.Version;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -28,7 +29,7 @@ import java.util.List;
import static junit.framework.Assert.assertEquals;
-public class HunspellStemmerTest {
+public class HunspellStemmerTest extends LuceneTestCase {
private static HunspellStemmer stemmer;
@@ -116,7 +117,7 @@ public class HunspellStemmerTest {
InputStream affixStream = HunspellStemmerTest.class.getResourceAsStream("test.aff");
InputStream dictStream = HunspellStemmerTest.class.getResourceAsStream("test.dic");
- HunspellDictionary dictionary = new HunspellDictionary(affixStream, dictStream, Version.LUCENE_40, ignoreCase);
+ HunspellDictionary dictionary = new HunspellDictionary(affixStream, dictStream, TEST_VERSION_CURRENT, ignoreCase);
stemmer = new HunspellStemmer(dictionary);
affixStream.close();
Modified: lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java (original)
+++ lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/CategoryEnhancement.java Thu Jan 12 18:55:30 2012
@@ -47,24 +47,24 @@ import org.apache.lucene.facet.taxonomy.
* @lucene.experimental
*/
public interface CategoryEnhancement {
-
+
/**
* Get the bytes to be added to the category token payload for this
* enhancement.
* <p>
- * <b>NOTE</b>: The returned array is copied, it is recommended to allocate
- * a new one each time.
+ * <b>NOTE</b>: The returned array is copied, it is recommended to allocate a
+ * new one each time.
* <p>
* The bytes generated by this method are the input of
* {@link #extractCategoryTokenData(byte[], int, int)}.
*
* @param categoryAttribute
- * The attribute of the category.
+ * The attribute of the category.
* @return The bytes to be added to the category token payload for this
* enhancement.
*/
byte[] getCategoryTokenBytes(CategoryAttribute categoryAttribute);
-
+
/**
* Get the data of this enhancement from a category token payload.
* <p>
@@ -72,56 +72,61 @@ public interface CategoryEnhancement {
* {@link #getCategoryTokenBytes(CategoryAttribute)}.
*
* @param buffer
- * The payload buffer.
+ * The payload buffer.
* @param offset
- * The offset of this enhancement's data in the buffer.
+ * The offset of this enhancement's data in the buffer.
* @param length
- * The length of this enhancement's data (bytes).
+ * The length of this enhancement's data (bytes).
* @return An Object containing the data.
*/
Object extractCategoryTokenData(byte[] buffer, int offset, int length);
-
+
/**
- * Declarative method to indicate whether this enhancement generates
- * separate category list.
+ * Declarative method to indicate whether this enhancement generates separate
+ * category list.
*
* @return {@code true} if generates category list, else {@code false}.
*/
boolean generatesCategoryList();
-
+
/**
* Returns the text of this enhancement's category list term.
*
* @return The text of this enhancement's category list term.
*/
String getCategoryListTermText();
-
+
/**
- * Get the {@link CategoryListTokenizer} which generates the category list
- * for this enhancement. If {@link #generatesCategoryList()} returns
- * {@code false} this method will not be called.
+ * Get the {@link CategoryListTokenizer} which generates the category list for
+ * this enhancement. If {@link #generatesCategoryList()} returns {@code false}
+ * this method will not be called.
*
* @param tokenizer
- * The input stream containing categories.
+ * The input stream containing categories.
* @param indexingParams
- * The indexing params to use.
+ * The indexing params to use.
* @param taxonomyWriter
- * The taxonomy to add categories and get their ordinals.
+ * The taxonomy to add categories and get their ordinals.
* @return A {@link CategoryListTokenizer} generating the category list for
* this enhancement, with {@code tokenizer} as it's input.
*/
CategoryListTokenizer getCategoryListTokenizer(TokenStream tokenizer,
- EnhancementsIndexingParams indexingParams,
- TaxonomyWriter taxonomyWriter);
-
+ EnhancementsIndexingParams indexingParams, TaxonomyWriter taxonomyWriter);
+
/**
* Get a {@link CategoryProperty} class to be retained when creating
* {@link CategoryParentsStream}.
*
* @return the {@link CategoryProperty} class to be retained when creating
- * {@link CategoryParentsStream}, or {@code null} if there is no
- * such property.
+ * {@link CategoryParentsStream}, or {@code null} if there is no such
+ * property.
*/
Class<? extends CategoryProperty> getRetainableProperty();
-
+
+ /**
+ * Category enhancements must override {@link Object#equals(Object)}, as it is
+ * used in
+ * {@link EnhancementsPayloadIterator#getCategoryData(CategoryEnhancement)}.
+ */
+ public boolean equals(Object o);
}
Modified: lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java (original)
+++ lucene/dev/branches/lucene3305/modules/facet/src/java/org/apache/lucene/facet/enhancements/association/AssociationEnhancement.java Thu Jan 12 18:55:30 2012
@@ -150,4 +150,17 @@ public class AssociationEnhancement impl
return null;
}
+ @Override
+ public boolean equals(Object o) {
+ if (o == this) {
+ return true;
+ }
+ return (o instanceof AssociationEnhancement);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
+
}
Modified: lucene/dev/branches/lucene3305/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java (original)
+++ lucene/dev/branches/lucene3305/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java Thu Jan 12 18:55:30 2012
@@ -34,6 +34,7 @@ import org.apache.lucene.search.similari
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.UnicodeUtil;
@@ -569,7 +570,7 @@ public final class MoreLikeThis {
public Query like(int docNum) throws IOException {
if (fieldNames == null) {
// gather list of valid fields from lucene
- Collection<String> fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
+ Collection<String> fields = ReaderUtil.getIndexedFields(ir);
fieldNames = fields.toArray(new String[fields.size()]);
}
Modified: lucene/dev/branches/lucene3305/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/CHANGES.txt?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene3305/solr/CHANGES.txt Thu Jan 12 18:55:30 2012
@@ -54,9 +54,6 @@ Upgrading from Solr 3.5-dev
legacy behavior should set a default value for the 'mm' param in
their solrconfig.xml file.
-* FacetComponent no longer catches and embeds exceptions occurred during facet
- processing, it throws HTTP 400 or 500 exceptions instead.
-
* The VelocityResponseWriter is no longer built into the core. Its JAR and
dependencies now need to be added (via <lib> or solr/home lib inclusion),
and it needs to be registered in solrconfig.xml like this:
@@ -397,6 +394,11 @@ Documentation
================== 3.6.0 ==================
+Upgrading from Solr 3.5
+----------------------
+* As doGet() methods in SimplePostTool was changed to static, the client applications of this
+ class need to be recompiled.
+
New Features
----------------------
* SOLR-2904: BinaryUpdateRequestHandler should be able to accept multiple update requests from
@@ -424,10 +426,12 @@ New Features
Optimizations
----------------------
-* SOLR-1931 Speedup for LukeRequestHandler and admin/schema browser. New parameter
+* SOLR-1931: Speedup for LukeRequestHandler and admin/schema browser. New parameter
reportDocCount defaults to 'false'. Old behavior still possible by specifying this as 'true'
(Erick Erickson)
+* SOLR-3012: Move System.getProperty("type") in postData() to main() and add type argument so that
+ the client applications of SimplePostTool can set content type via method argument. (koji)
Bug Fixes
----------------------
@@ -444,6 +448,9 @@ Bug Fixes
* SOLR-2956: Fixed inconsistencies in the flags (and flag key) reported by
the LukeRequestHandler (hossman)
+
+* SOLR-3024: Fixed JSONTestUtil.matchObj, in previous releases it was not
+ respecting the 'delta' arg (David Smiley via hossman)
Other Changes
----------------------
@@ -588,6 +595,9 @@ Upgrading from Solr 3.3
"true" for consistent behavior with previous Solr versions. This
situation has now been fixed to cause an error on startup when these
contradictory options. See SOLR-2669.
+
+* FacetComponent no longer catches and embeds exceptions occurred during facet
+ processing, it throws HTTP 400 or 500 exceptions instead.
New Features
----------------------
Modified: lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java Thu Jan 12 18:55:30 2012
@@ -27,13 +27,11 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.document.Field;
import org.apache.lucene.index.*;
import org.apache.lucene.index.FieldInfo.IndexOptions;
-import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_ONLY;
-import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_AND_FREQS;
-
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.solr.analysis.CharFilterFactory;
import org.apache.solr.analysis.TokenFilterFactory;
@@ -55,7 +53,9 @@ import org.apache.solr.schema.SchemaFiel
import org.apache.solr.search.SolrIndexSearcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.lucene.index.DocsEnum;
+
+import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_AND_FREQS;
+import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_ONLY;
/**
* This handler exposes the internal lucene index. It is inspired by and
@@ -289,11 +289,15 @@ public class LukeRequestHandler extends
IndexReader reader = searcher.getIndexReader();
IndexSchema schema = searcher.getSchema();
+ Set<String> fieldNames = new TreeSet<String>();
+ for(FieldInfo fieldInfo : ReaderUtil.getMergedFieldInfos(reader)) {
+ fieldNames.add(fieldInfo.name);
+ }
+
// Walk the term enum and keep a priority queue for each map in our set
SimpleOrderedMap<Object> finfo = new SimpleOrderedMap<Object>();
Fields theFields = MultiFields.getFields(reader);
- Set<String> fieldNames = new TreeSet<String>(reader.getFieldNames(IndexReader.FieldOption.ALL));
for (String fieldName : fieldNames) {
if (fields != null && ! fields.contains(fieldName)) {
continue; // we're not interested in this term
Modified: lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java Thu Jan 12 18:55:30 2012
@@ -38,6 +38,7 @@ import org.apache.lucene.store.FSDirecto
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.OpenBitSet;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
@@ -180,7 +181,10 @@ public class SolrIndexSearcher extends I
}
optimizer = solrConfig.filtOptEnabled ? new LuceneQueryOptimizer(solrConfig.filtOptCacheSize,solrConfig.filtOptThreshold) : null;
- fieldNames = r.getFieldNames(IndexReader.FieldOption.ALL);
+ fieldNames = new HashSet<String>();
+ for(FieldInfo fieldInfo : ReaderUtil.getMergedFieldInfos(r)) {
+ fieldNames.add(fieldInfo.name);
+ }
// do this at the end since an exception in the constructor means we won't close
numOpens.incrementAndGet();
@@ -421,8 +425,6 @@ public class SolrIndexSearcher extends I
public void stringField(FieldInfo fieldInfo, String value) throws IOException {
final FieldType ft = new FieldType(TextField.TYPE_STORED);
ft.setStoreTermVectors(fieldInfo.storeTermVector);
- ft.setStoreTermVectorPositions(fieldInfo.storePositionWithTermVector);
- ft.setStoreTermVectorOffsets(fieldInfo.storeOffsetWithTermVector);
ft.setStoreTermVectors(fieldInfo.storeTermVector);
ft.setIndexed(fieldInfo.isIndexed);
ft.setOmitNorms(fieldInfo.omitNorms);
Modified: lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/search/function/FileFloatSource.java Thu Jan 12 18:55:30 2012
@@ -255,10 +255,9 @@ public class FileFloatSource extends Val
String key = line.substring(0, delimIndex);
String val = line.substring(delimIndex+1, endIndex);
- idType.readableToIndexed(key, internalKey);
-
float fval;
try {
+ idType.readableToIndexed(key, internalKey);
fval=Float.parseFloat(val);
} catch (Exception e) {
if (++otherErrors<=10) {
Modified: lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/util/SimplePostTool.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/java/org/apache/solr/util/SimplePostTool.java Thu Jan 12 18:55:30 2012
@@ -44,7 +44,7 @@ public class SimplePostTool {
private static final String DEFAULT_OPTIMIZE = "no";
private static final String DEFAULT_OUT = "no";
- private static final String DEFAULT_DATA_TYPE = "application/xml";
+ public static final String DEFAULT_DATA_TYPE = "application/xml";
private static final String DATA_MODE_FILES = "files";
private static final String DATA_MODE_ARGS = "args";
@@ -89,6 +89,7 @@ public class SimplePostTool {
}
OutputStream out = null;
+ final String type = System.getProperty("type", DEFAULT_DATA_TYPE);
URL u = null;
try {
@@ -111,7 +112,7 @@ public class SimplePostTool {
if (DATA_MODE_FILES.equals(mode)) {
if (0 < args.length) {
info("POSTing files to " + u + "..");
- t.postFiles(args, 0, out);
+ t.postFiles(args, 0, out, type);
} else {
info("No files specified. (Use -h for help)");
}
@@ -120,13 +121,13 @@ public class SimplePostTool {
if (0 < args.length) {
info("POSTing args to " + u + "..");
for (String a : args) {
- t.postData(SimplePostTool.stringToStream(a), null, out);
+ t.postData(SimplePostTool.stringToStream(a), null, out, type);
}
}
} else if (DATA_MODE_STDIN.equals(mode)) {
info("POSTing stdin to " + u + "..");
- t.postData(System.in, null, out);
+ t.postData(System.in, null, out, type);
}
if ("yes".equals(System.getProperty("commit",DEFAULT_COMMIT))) {
info("COMMITting Solr index changes..");
@@ -142,15 +143,24 @@ public class SimplePostTool {
fatal("RuntimeException " + e);
}
}
-
- /** Post all filenames provided in args, return the number of files posted*/
+
+ /**
+ * @deprecated use {@link #postData(InputStream, Integer, OutputStream, String)} instead
+ */
+ @Deprecated
int postFiles(String [] args,int startIndexInArgs, OutputStream out) {
+ final String type = System.getProperty("type", DEFAULT_DATA_TYPE);
+ return postFiles(args, startIndexInArgs, out, type);
+ }
+
+ /** Post all filenames provided in args, return the number of files posted*/
+ int postFiles(String [] args,int startIndexInArgs, OutputStream out, String type) {
int filesPosted = 0;
for (int j = startIndexInArgs; j < args.length; j++) {
File srcFile = new File(args[j]);
if (srcFile.canRead()) {
info("POSTing file " + srcFile.getName());
- postFile(srcFile, out);
+ postFile(srcFile, out, type);
filesPosted++;
} else {
warn("Cannot read input file: " + srcFile);
@@ -199,16 +209,24 @@ public class SimplePostTool {
}
/**
+ * @deprecated use {@link #postFile(File, OutputStream, String)} instead
+ */
+ public void postFile(File file, OutputStream output) {
+ final String type = System.getProperty("type", DEFAULT_DATA_TYPE);
+ postFile(file, output, type);
+ }
+
+ /**
* Opens the file and posts it's contents to the solrUrl,
* writes to response to output.
* @throws UnsupportedEncodingException
*/
- public void postFile(File file, OutputStream output) {
+ public void postFile(File file, OutputStream output, String type) {
InputStream is = null;
try {
is = new FileInputStream(file);
- postData(is, (int)file.length(), output);
+ postData(is, (int)file.length(), output, type);
} catch (IOException e) {
fatal("Can't open/read file: " + file);
} finally {
@@ -224,7 +242,7 @@ public class SimplePostTool {
* Performs a simple get on the given URL
* @param url
*/
- public void doGet(String url) {
+ public static void doGet(String url) {
try {
doGet(new URL(url));
} catch (MalformedURLException e) {
@@ -236,7 +254,7 @@ public class SimplePostTool {
* Performs a simple get on the given URL
* @param url
*/
- public void doGet(URL url) {
+ public static void doGet(URL url) {
try {
HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
if (HttpURLConnection.HTTP_OK != urlc.getResponseCode()) {
@@ -249,12 +267,19 @@ public class SimplePostTool {
}
/**
- * Reads data from the data stream and posts it to solr,
- * writes to the response to output
+ * @deprecated use {@link #postData(InputStream, Integer, OutputStream, String)} instead
*/
+ @Deprecated
public void postData(InputStream data, Integer length, OutputStream output) {
-
final String type = System.getProperty("type", DEFAULT_DATA_TYPE);
+ postData(data, length, output, type);
+ }
+
+ /**
+ * Reads data from the data stream and posts it to solr,
+ * writes to the response to output
+ */
+ public void postData(InputStream data, Integer length, OutputStream output, String type) {
HttpURLConnection urlc = null;
try {
@@ -308,7 +333,7 @@ public class SimplePostTool {
}
}
- private static InputStream stringToStream(String s) {
+ public static InputStream stringToStream(String s) {
InputStream is = null;
try {
is = new ByteArrayInputStream(s.getBytes("UTF-8"));
@@ -320,7 +345,7 @@ public class SimplePostTool {
/**
* Pipes everything from the source to the dest. If dest is null,
- * then everything is read fro msource and thrown away.
+ * then everything is read from source and thrown away.
*/
private static void pipe(InputStream source, OutputStream dest) throws IOException {
byte[] buf = new byte[1024];
Modified: lucene/dev/branches/lucene3305/solr/core/src/test-files/solr/conf/schema11.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/test-files/solr/conf/schema11.xml?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/test-files/solr/conf/schema11.xml (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/test-files/solr/conf/schema11.xml Thu Jan 12 18:55:30 2012
@@ -273,7 +273,7 @@ valued. -->
stored="false" indexed="true"
class="solr.ExternalFileField" valType="float"/>
- <fieldType name="eff_tfloat" keyField="id" defVal="0"
+ <fieldType name="eff_tfloat" keyField="eff_ti" defVal="0"
stored="false" indexed="true"
class="solr.ExternalFileField" valType="tfloat"/>
@@ -320,6 +320,8 @@ valued. -->
<field name="signatureField" type="string" indexed="true" stored="false"/>
+ <field name="eff_trie" type="eff_tfloat" />
+
<!-- Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
Modified: lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/TestDocSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/TestDocSet.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/TestDocSet.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/TestDocSet.java Thu Jan 12 18:55:30 2012
@@ -17,22 +17,23 @@
package org.apache.solr.search;
-import java.util.Random;
-import java.util.Arrays;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.Random;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.OpenBitSet;
-import org.apache.lucene.util.OpenBitSetIterator;
+import org.apache.lucene.index.FieldInfos;
+import org.apache.lucene.index.FilterIndexReader;
import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.FilterIndexReader;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.IndexReader.ReaderContext;
import org.apache.lucene.index.MultiReader;
-import org.apache.lucene.search.Filter;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.OpenBitSet;
+import org.apache.lucene.util.OpenBitSetIterator;
/**
*
@@ -358,6 +359,11 @@ public class TestDocSet extends LuceneTe
public IndexReader[] getSequentialSubReaders() {
return null;
}
+
+ @Override
+ public FieldInfos getFieldInfos() {
+ return new FieldInfos();
+ }
};
return r;
}
Modified: lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java (original)
+++ lucene/dev/branches/lucene3305/solr/core/src/test/org/apache/solr/search/function/TestFunctionQuery.java Thu Jan 12 18:55:30 2012
@@ -296,6 +296,18 @@ public class TestFunctionQuery extends S
}
@Test
+ public void testExternalFileFieldNumericKey() throws Exception {
+ final String extField = "eff_trie";
+ final String keyField = "eff_ti";
+ assertU(adoc("id", "991", keyField, "91"));
+ assertU(adoc("id", "992", keyField, "92"));
+ assertU(adoc("id", "993", keyField, "93"));
+ assertU(commit());
+ makeExternalFile(extField, "91=543210\n92=-8\n93=250\n=67","UTF-8");
+ singleTest(extField,"\0",991,543210,992,-8,993,250);
+ }
+
+ @Test
public void testGeneral() throws Exception {
clearIndex();
Modified: lucene/dev/branches/lucene3305/solr/solrj/src/java/org/apache/solr/common/SolrException.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/solrj/src/java/org/apache/solr/common/SolrException.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/solrj/src/java/org/apache/solr/common/SolrException.java (original)
+++ lucene/dev/branches/lucene3305/solr/solrj/src/java/org/apache/solr/common/SolrException.java Thu Jan 12 18:55:30 2012
@@ -58,14 +58,11 @@ public class SolrException extends Runti
public boolean logged=false;
public SolrException(ErrorCode code, String msg) {
- super(msg);
- this.code=code.code;
+ this(code, msg, null, false);
}
public SolrException(ErrorCode code, String msg, boolean alreadyLogged) {
- super(msg);
- this.code=code.code;
- this.logged=alreadyLogged;
+ this(code, msg, null, alreadyLogged);
}
public SolrException(ErrorCode code, String msg, Throwable th, boolean alreadyLogged) {
@@ -75,13 +72,11 @@ public class SolrException extends Runti
}
public SolrException(ErrorCode code, String msg, Throwable th) {
- this(code,msg,th,true);
+ this(code, msg, th, (th instanceof SolrException) ? ((SolrException)th).logged : false);
}
public SolrException(ErrorCode code, Throwable th) {
- super(th);
- this.code=code.code;
- logged=true;
+ this(code, null, th, (th instanceof SolrException) ? ((SolrException)th).logged : false);
}
/**
Modified: lucene/dev/branches/lucene3305/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3305/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java?rev=1230702&r1=1230701&r2=1230702&view=diff
==============================================================================
--- lucene/dev/branches/lucene3305/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java (original)
+++ lucene/dev/branches/lucene3305/solr/test-framework/src/java/org/apache/solr/JSONTestUtil.java Thu Jan 12 18:55:30 2012
@@ -78,7 +78,7 @@ public class JSONTestUtil {
public static String match(String path, String input, String expected, double delta) throws Exception {
Object inputObj = ObjectBuilder.fromJSON(input);
Object expectObj = ObjectBuilder.fromJSON(expected);
- return matchObj(path, inputObj, expectObj);
+ return matchObj(path, inputObj, expectObj, delta);
}
/**
@@ -88,7 +88,7 @@ public class JSONTestUtil {
* @param delta tollerance allowed in comparing float/double values
*/
public static String matchObj(String path, Object input, Object expected, double delta) throws Exception {
- CollectionTester tester = new CollectionTester(input);
+ CollectionTester tester = new CollectionTester(input,delta);
boolean reversed = path.startsWith("!");
String positivePath = reversed ? path.substring(1) : path;
if (!tester.seek(positivePath) ^ reversed) {
@@ -181,19 +181,16 @@ class CollectionTester {
// make an exception for some numerics
if ((expected instanceof Integer && val instanceof Long || expected instanceof Long && val instanceof Integer)
- && ((Number)expected).longValue() == ((Number)val).longValue())
- {
+ && ((Number)expected).longValue() == ((Number)val).longValue()) {
return true;
- } else if ((expected instanceof Float && val instanceof Double || expected instanceof Double && val instanceof Float)) {
+ } else if ((expected instanceof Double || expected instanceof Float) && (val instanceof Double || val instanceof Float)) {
double a = ((Number)expected).doubleValue();
double b = ((Number)val).doubleValue();
if (Double.compare(a,b) == 0) return true;
if (Math.abs(a-b) < delta) return true;
- return false;
- } else {
- setErr("mismatch: '" + expected + "'!='" + val + "'");
- return false;
}
+ setErr("mismatch: '" + expected + "'!='" + val + "'");
+ return false;
}
// setErr("unknown expected type " + expected.getClass().getName());