mirror of https://github.com/apache/lucene.git
I have modified the SortedField to not access deleted documents. This caused an exception when filling the initial arrays.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150812 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a75302f000
commit
3940b6ff1c
|
@ -10,7 +10,7 @@ package org.apache.lucene.beans;
|
|||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -54,7 +54,7 @@ public class SortedField {
|
|||
* @param fieldName the name of the field to add
|
||||
* @param directory Lucene Directory
|
||||
*/
|
||||
public static void addField(String fieldName, Directory directory) throws IOException{
|
||||
public static void addField(String fieldName, Directory directory) throws IOException{
|
||||
IndexReader ir = IndexReader.open(directory);
|
||||
addField(fieldName, ir);
|
||||
}
|
||||
|
@ -73,7 +73,11 @@ public class SortedField {
|
|||
int numDocs = ir.numDocs();
|
||||
fieldValues = new String[numDocs];
|
||||
for (int i=0; i<numDocs; i++) {
|
||||
fieldValues[i] = ir.document(i).get(fieldName);
|
||||
if (ir.isDeleted(i) == false){
|
||||
fieldValues[i] = ir.document(i).get(fieldName);
|
||||
} else {
|
||||
fieldValues[i] = "";
|
||||
}
|
||||
}
|
||||
ir.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue