Check if paper object is not null before inserting
This commit is contained in:
parent
a4d505ce06
commit
9dbfe1ccc4
|
@ -80,11 +80,13 @@ public class Indexer {
|
|||
Document doc = new Document();
|
||||
doc.add(new StringField("document_id", paper.paper_id, Field.Store.YES));
|
||||
doc.add(new TextField("title", paper.metadata.title, Field.Store.YES));
|
||||
StringBuilder authors = new StringBuilder();
|
||||
for (Author author : paper.metadata.authors) {
|
||||
String authorName = author.first + " " + author.middle + " " + author.last;
|
||||
authorName = authorName.replaceAll("\\p{P}", "");
|
||||
doc.add(new TextField("authors", authorName, Field.Store.YES));
|
||||
authors.append(authorName);
|
||||
}
|
||||
doc.add(new TextField("authors", authors.toString(), Field.Store.YES));
|
||||
StringBuilder fullAbstract = new StringBuilder();
|
||||
for (Abstract abstract_ : paper.abstract_) {
|
||||
fullAbstract.append(abstract_.text);
|
||||
|
@ -102,7 +104,9 @@ public class Indexer {
|
|||
createIndex();
|
||||
for (File file : files) {
|
||||
Paper paper = parseJSONFile(file);
|
||||
addDocument(paper);
|
||||
if (paper != null) {
|
||||
addDocument(paper);
|
||||
}
|
||||
}
|
||||
commitChanges();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue