From a4d505ce06a01a0b3d8a28b6936e27cb9136c1c1 Mon Sep 17 00:00:00 2001 From: coolneng Date: Mon, 11 Jan 2021 19:23:43 +0100 Subject: [PATCH] Index the abstract --- .gitignore | 1 + src/main/java/org/RI/P2/Indexer.java | 5 +++++ src/main/java/org/RI/P2/Paper.java | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 45647a1..0702298 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ data data-test target output +.index diff --git a/src/main/java/org/RI/P2/Indexer.java b/src/main/java/org/RI/P2/Indexer.java index c0de104..3d2af20 100644 --- a/src/main/java/org/RI/P2/Indexer.java +++ b/src/main/java/org/RI/P2/Indexer.java @@ -85,6 +85,11 @@ public class Indexer { authorName = authorName.replaceAll("\\p{P}", ""); doc.add(new TextField("authors", authorName, Field.Store.YES)); } + StringBuilder fullAbstract = new StringBuilder(); + for (Abstract abstract_ : paper.abstract_) { + fullAbstract.append(abstract_.text); + } + doc.add(new TextField("abstract", fullAbstract.toString(), Field.Store.NO)); index.addDocument(doc); } diff --git a/src/main/java/org/RI/P2/Paper.java b/src/main/java/org/RI/P2/Paper.java index e443c1f..a6c01ae 100644 --- a/src/main/java/org/RI/P2/Paper.java +++ b/src/main/java/org/RI/P2/Paper.java @@ -2,6 +2,8 @@ package org.RI.P2; import java.util.List; +import com.google.gson.annotations.SerializedName; + class Affiliation { String laboratory; String institution; @@ -40,6 +42,7 @@ class Body_Text { public class Paper { String paper_id; Metadata metadata; - List _abstract; + @SerializedName("abstract") + List abstract_; List body_text; }