Index authors' emails

This commit is contained in:
coolneng 2021-01-11 20:09:47 +01:00
parent b1d6afb7fe
commit 7e56aae1a2
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 6 additions and 8 deletions

View File

@ -47,9 +47,12 @@ public class Indexer {
PerFieldAnalyzerWrapper createAnalyzer() {
Map<String, Analyzer> analyzerPerField = new HashMap<>();
analyzerPerField.put("document_id", new StandardAnalyzer());
analyzerPerField.put("title", new EnglishAnalyzer());
analyzerPerField.put("abstract", new EnglishAnalyzer());
analyzerPerField.put("authors", new StandardAnalyzer());
analyzerPerField.put("institutions", new StandardAnalyzer());
analyzerPerField.put("emails", new StandardAnalyzer());
PerFieldAnalyzerWrapper customAnalyzer = new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer(),
analyzerPerField);
return customAnalyzer;
@ -82,14 +85,17 @@ public class Indexer {
doc.add(new TextField("title", paper.metadata.title, Field.Store.YES));
StringBuilder authors = new StringBuilder();
StringBuilder institutions = new StringBuilder();
StringBuilder emails = new StringBuilder();
for (Author author : paper.metadata.authors) {
String authorName = author.first + " " + author.middle + " " + author.last;
authorName = authorName.replaceAll("\\p{P}", "");
authors.append(authorName);
institutions.append(author.affiliation.institution);
emails.append(author.email);
}
doc.add(new TextField("authors", authors.toString(), Field.Store.YES));
doc.add(new TextField("institution", institutions.toString(), Field.Store.NO));
doc.add(new TextField("emails", emails.toString(), Field.Store.NO));
StringBuilder fullAbstract = new StringBuilder();
for (Abstract abstr : paper.abstr) {
fullAbstract.append(abstr.text);

View File

@ -9,20 +9,12 @@ class Affiliation {
String institution;
}
class Location {
String postCode;
String settlement;
String region;
String country;
}
class Author {
String first;
List<String> middle;
String last;
String suffix;
Affiliation affiliation;
Location location;
String email;
}