Hi,
When using a full text index on a field if I update a field that is currently null with a value then the full text indexing of the new value throws a NullPointerException. I've put the stack trace below along with example code that demonstrates the issue. I've found this in 3.4.2 I'm wondering if it's possibly related to the fix for #222
Exception in thread "main" java.lang.NullPointerException
at java.base/java.util.StringTokenizer.<init>(StringTokenizer.java:199)
at java.base/java.util.StringTokenizer.<init>(StringTokenizer.java:221)
at org.dizitart.no2.fulltext.BaseTextTokenizer.tokenize(BaseTextTokenizer.java:40)
at org.dizitart.no2.internals.NitriteTextIndexingService.deleteIndex(NitriteTextIndexingService.java:65)
at org.dizitart.no2.internals.IndexingService.refreshIndexEntry(IndexingService.java:206)
at org.dizitart.no2.internals.DataService.update(DataService.java:182)
at org.dizitart.no2.internals.NitriteService.update(NitriteService.java:443)
at org.dizitart.no2.internals.DefaultNitriteCollection.update(DefaultNitriteCollection.java:322)
at scrap.NitriteIndexNull.main(NitriteIndexNull.java:42)
package scrap;
import java.io.File;
import org.dizitart.no2.Document;
import org.dizitart.no2.IndexOptions;
import org.dizitart.no2.IndexType;
import org.dizitart.no2.Nitrite;
import org.dizitart.no2.NitriteCollection;
import org.dizitart.no2.NitriteId;
import org.dizitart.no2.UpdateOptions;
import org.dizitart.no2.WriteResult;
import org.dizitart.no2.filters.Filters;
public class NitriteIndexNull {
public static void main(String[] args) {
File dbFile = new File("/tmp/nitrite.db");
if(dbFile.exists()) {
dbFile.delete();
}
//create database
Nitrite nitrite = Nitrite.builder().filePath("/tmp/nitrite.db").openOrCreate();
//create collection
NitriteCollection collection = nitrite.getCollection("col");
//add a record
Document doc = Document.createDocument("FIELD1", "ABC");
doc.put("FIELD2", null);
WriteResult result = collection.update(Filters.eq("FIELD1", "ABC"), doc, UpdateOptions.updateOptions(true, true));
//get the ID
Long id = result.iterator().next().getIdValue();
//create an indexed field
collection.createIndex("FIELD2", IndexOptions.indexOptions(IndexType.Fulltext));
//get document back out
doc = collection.getById(NitriteId.createId(id));
//insert a null into the field
doc.put("FIELD2", null);
collection.update(Filters.eq("FIELD1", "ABC"), doc, UpdateOptions.updateOptions(true, true));
//update the null field with an value
doc.put("FIELD2", "DEF");
collection.update(Filters.eq("FIELD1", "ABC"), doc, UpdateOptions.updateOptions(true, true));
}
}
Hi,
When using a full text index on a field if I update a field that is currently
nullwith a value then the full text indexing of the new value throws aNullPointerException. I've put the stack trace below along with example code that demonstrates the issue. I've found this in 3.4.2 I'm wondering if it's possibly related to the fix for #222