Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search in PDF Files #2838

Merged
merged 122 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from 119 commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
321a0f0
Add lucene to gradle.build dependencies
Braunch Aug 2, 2016
2580757
Implement first attempt on a lucene powerded indexed search machine f…
Braunch Aug 2, 2016
a9d85dc
Ignore test and improve search handler and content reader to map bibt…
Braunch Aug 4, 2016
753c25d
Create search result wrapper classes for better readability of future…
Braunch Aug 4, 2016
6d1cb44
Add lucene score and collector for search meta data retrieval in the …
Braunch Aug 4, 2016
1af3f1a
Add example pdf and create test skeleton
Braunch Aug 4, 2016
40609ad
Merge branch 'PDFSearchFeature' of github.com:Braunch/jabref into lucene
LinusDietz Apr 20, 2017
8787bcd
import fulltext search from Braunch:PDFSearchFeature
LinusDietz Apr 20, 2017
d51919e
Merge branch 'master' of github.com:JabRef/jabref into lucene
LinusDietz May 10, 2017
692316b
Refactored the PDFContentReader
LinusDietz May 10, 2017
dacbc3c
Put DocumentReader under test
LinusDietz May 10, 2017
2663798
Use current Lucene Release, Indexing is working now.
LinusDietz May 10, 2017
7086a8f
Revised package structure
LinusDietz May 12, 2017
444bd39
added stem analysis
LinusDietz May 12, 2017
8547873
Implemented Searcher Test
LinusDietz May 12, 2017
c9cf893
Improve Naming
LinusDietz May 12, 2017
9eaa390
fix build
LinusDietz May 12, 2017
c83255b
First round of Feedback
LinusDietz May 14, 2017
25cdaff
Second round of Feedback
LinusDietz May 14, 2017
b7bfc9a
Removed PDF Creator from the Search index, add the UID to the search …
LinusDietz May 14, 2017
9a71cac
fixed failing test
LinusDietz May 15, 2017
aa76b72
Merge branch 'master' of https://github.com/JabRef/jabref into lucene
LinusDietz Aug 29, 2017
aed867d
update Lucene from 6.5.1 -> 6.6.0
LinusDietz Aug 29, 2017
a9a9486
integrate indexing into Jabref
LinusDietz Aug 29, 2017
b32af3c
Merge branch 'master' of https://github.com/JabRef/jabref into lucene
LinusDietz Oct 4, 2017
e64c3da
Merge branch 'master' of https://github.com/JabRef/jabref into lucene
LinusDietz Dec 20, 2017
9cd3df3
Update lucene from 6.6.0 -> 7.1.0
LinusDietz Dec 20, 2017
a12555a
Merge branch 'master' into lucene
LinusDietz Jan 23, 2018
e2662cd
Merge branch 'master' of https://github.com/JabRef/jabref into lucene
LinusDietz Jan 23, 2018
650c050
Merge branch 'lucene' of https://github.com/JabRef/jabref into lucene
LinusDietz Jan 23, 2018
a6fad30
Update lucene from 7.1.0 -> 7.2.1
LinusDietz Jan 23, 2018
74c90bd
Merge branch lucene of https://github.com/JabRef/jabref into lucene
btut Jun 16, 2021
6d9ba0b
Lucene dependencies
btut Jun 16, 2021
1a53c47
First shot for integrating lucene
koppor Jun 16, 2021
71a9cb0
Fix and document dependencies
btut Jun 18, 2021
4125ee8
Update to lucene 8.8.2
btut Jun 18, 2021
dd698ff
Checkstyle
btut Jun 18, 2021
e247540
Added fulltext-search button to GlobalSearchBar
btut Jun 18, 2021
63c2abf
Fixed typo
btut Jun 18, 2021
f6e2058
Update to lucene 8.9.0
btut Jun 21, 2021
3ba53be
Added update/remove from index for individual entries/files
btut Jun 22, 2021
4f5c8ed
Started integrating indexer
btut Jun 23, 2021
596525f
Ignore lucene index in git
btut Jun 23, 2021
516d1ca
Fixed tests
btut Jun 23, 2021
4de4dbe
Checkstyle
btut Jun 23, 2021
d83ae36
First draft of search-results tab
btut Jun 23, 2021
a32bec7
Merge branch 'main' of github.com:JabRef/jabref into lucene
btut Jun 28, 2021
addf51e
No tabs in build.gradle
btut Jun 29, 2021
4a3d3c8
Code cleanup
btut Jun 29, 2021
cb30b3b
Added highlighting dependency
btut Jun 29, 2021
8c9bf3c
Highlighted search results
btut Jun 29, 2021
651ef23
Added lib to access local app-data path
btut Jul 5, 2021
7804060
SearchRules only for single DatabaseContext
btut Jul 5, 2021
2c7dc25
Before reverting
btut Jul 5, 2021
148b4f6
Revert "SearchRules only for single DatabaseContext"
btut Jul 5, 2021
edc6fe4
Better SearchRules only for single DatabaseContext
btut Jul 5, 2021
2557fee
Fixed document duplication on update
btut Jul 5, 2021
b4a9c7a
Only write files if index is out of date
btut Jul 5, 2021
786828d
Use globals instead of passing BibDatabaseContext
btut Jul 6, 2021
25c3a40
Fixed tests
btut Jul 7, 2021
4646ab4
Checkstyle
btut Jul 7, 2021
67a7d0a
Ignore index created during tests in git
btut Jul 7, 2021
90ee454
Removed unused localization key
btut Jul 7, 2021
181e382
Listen for changes that concern the index
btut Jul 7, 2021
86d73d0
Added menu-item to rebuild index
btut Jul 7, 2021
a8781ae
Allow SearchRules to access Globals
btut Jul 8, 2021
85beb5c
Moved access to Globals to constructor
btut Jul 8, 2021
c7f3bc8
Removed most metadata from index
btut Jul 8, 2021
e511cbd
Do indexing per Library-tab
btut Jul 8, 2021
b61e14f
Removed tests for Metadata in DocumentReader
btut Jul 8, 2021
ebd9313
Consider cases where there is no open database
btut Jul 8, 2021
cffe5b5
Actually consider fulltext results in search predicate
btut Jul 8, 2021
4f546d1
Applied theme to search-results tab
btut Jul 8, 2021
8c3e76c
Files can be opened from the search-results tab
btut Jul 8, 2021
85a048b
Merge branch 'main' of github.com:JabRef/jabref into lucene
btut Jul 8, 2021
030d5b3
Fixed merge-artifact
btut Jul 8, 2021
acea590
Fixed file-type filter in indexer
btut Jul 8, 2021
18aac31
Changelog entry
btut Jul 8, 2021
6d40f7a
Fixed file types in tests
btut Jul 8, 2021
da3ed1e
Checkstyle
btut Jul 8, 2021
99decc1
Fixed benchmarks
btut Jul 8, 2021
5bde996
Removed spaces in CHANGELOG
btut Jul 8, 2021
a4cd102
Removed unecessary code in shadow-jar for lucene
btut Jul 9, 2021
856e20f
Removed weird endless recursion
btut Jul 9, 2021
33e6c4a
Fixed Typo in comment
btut Jul 9, 2021
27f201d
Use parseLong instead of valueOf
btut Jul 9, 2021
cfc5869
Rescoped BibDatabase variable
btut Jul 9, 2021
effbfdc
Use method instance
btut Jul 9, 2021
2e5818b
Remove unecessary return
btut Jul 9, 2021
adb195e
Remove unnecessary throws declaration
btut Jul 9, 2021
9e10107
Cleaner sort-predicate
btut Jul 9, 2021
8a8ac9c
Limit number of search result to 5
btut Jul 10, 2021
1bf636a
Apply suggestions from code review
btut Jul 10, 2021
989e266
Fixed logger formating
btut Jul 10, 2021
5f093d7
Add log for index-location
btut Jul 10, 2021
298a0d9
Log IO exception when rebuilding index from menu
btut Jul 10, 2021
2d711d4
Localized search results tab
btut Jul 10, 2021
2b879fa
Moved logging to slf4j
btut Jul 10, 2021
8afa013
Log search-result exception
btut Jul 10, 2021
e968483
Better naming for task queue pointer
btut Jul 10, 2021
63eb1a1
Replaced deprecated classes and methods
btut Jul 10, 2021
b500ba2
Removed unnecessary wrapping of unmodifyable list
btut Jul 10, 2021
a554a36
Simplify iteration over search results
btut Jul 10, 2021
36099a8
Use TempDir to store the index during tests
btut Jul 10, 2021
44c975f
Use EnumSet for flags instead of booleans
btut Jul 10, 2021
cb1c393
Delete out-of-date indices
btut Jul 10, 2021
99e723e
Fixed import order
btut Jul 10, 2021
82b9d69
Task-queue and better message for indexing task
btut Jul 10, 2021
cec2089
Remove empty line
koppor Jul 13, 2021
e69219b
Update src/main/java/org/jabref/gui/JabRefMain.java
koppor Jul 13, 2021
533331a
Merge branch 'main' into lucene
koppor Jul 13, 2021
bfd2582
Use literal JabRef for index path
btut Jul 14, 2021
46517ff
Apply suggestions from @koppor
btut Jul 14, 2021
9c887a3
Checkstyle
btut Jul 14, 2021
dc9f53d
Removed dead code
btut Jul 14, 2021
7601ce6
Removed more dead code
btut Jul 14, 2021
5dc3852
Add annotations to index
btut Jul 14, 2021
110601c
Checkstyle
btut Jul 14, 2021
964aa1f
Error handling when reading annotations
btut Jul 14, 2021
25d5733
Remove hardcoded appdata path
btut Jul 14, 2021
79ae32b
Refine toString
koppor Jul 14, 2021
e6055fc
Rename method
koppor Jul 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Added

- We added a fulltext search feature. [#2838](https://github.com/JabRef/jabref/pull/2838)

### Changed

### Fixed
Expand Down
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ dependencies {
antlr4 'org.antlr:antlr4:4.9.2'
implementation 'org.antlr:antlr4-runtime:4.9.2'

implementation (group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.9.0') {
exclude group: 'org.apache.lucene', module: 'lucene-sandbox'
}

implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.12.0.202106070339-r'

implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.12.4'
Expand Down Expand Up @@ -209,6 +205,8 @@ dependencies {
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-strikethrough:0.62.2'
implementation 'com.vladsch.flexmark:flexmark-ext-gfm-tasklist:0.62.2'

implementation group: 'net.harawata', name: 'appdirs', version: '1.2.1'

testImplementation 'io.github.classgraph:classgraph:4.8.110'
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.2'
Expand Down
5 changes: 4 additions & 1 deletion external-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ License: Apache-2.0
```

```yaml
Id: org.apache.lucene:lucene-ueryparser
Id: org.apache.lucene:lucene-queryparser
Project: Apache Lucene
URL: https://lucene.apache.org/
License: Apache-2.0
Expand Down Expand Up @@ -567,6 +567,9 @@ org.apache.logging.log4j:log4j-slf4j18-impl:3.0.0-SNAPSHOT
org.apache.lucene:lucene-core:8.9.0
org.apache.lucene:lucene-queries:8.9.0
org.apache.lucene:lucene-queryparser:8.9.0
org.apache.lucene:lucene-analyzers-common:8.9.0
org.apache.lucene:lucene-backward-codecs:8.9.0
org.apache.lucene:lucene-highlighter:8.9.0
org.apache.pdfbox:fontbox:2.0.24
org.apache.pdfbox:pdfbox:2.0.24
org.apache.pdfbox:xmpbox:2.0.24
Expand Down
Binary file added lib/lucene.jar
Binary file not shown.
23 changes: 23 additions & 0 deletions lucene-jar/lib/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
plugins {
id 'java-library'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}

repositories {
mavenCentral()
}

shadowJar {
mergeServiceFiles()
}

dependencies {
implementation 'org.apache.lucene:lucene-core:8.9.0'
implementation ('org.apache.lucene:lucene-queryparser:8.9.0') {
exclude module: "lucene-sandbox"
}
implementation 'org.apache.lucene:lucene-queries:8.9.0'
implementation 'org.apache.lucene:lucene-analyzers-common:8.9.0'
implementation 'org.apache.lucene:lucene-backward-codecs:8.9.0'
implementation 'org.apache.lucene:lucene-highlighter:8.9.0'
}
11 changes: 11 additions & 0 deletions lucene-jar/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.0.2/userguide/multi_project_builds.html
*/

rootProject.name = 'lucene-jar'
include('lib')
6 changes: 4 additions & 2 deletions src/jmh/java/org/jabref/benchmarks/Benchmarks.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
Expand All @@ -28,6 +29,7 @@
import org.jabref.model.groups.KeywordGroup;
import org.jabref.model.groups.WordKeywordGroup;
import org.jabref.model.metadata.MetaData;
import org.jabref.model.search.rules.SearchRules.SearchFlags;
import org.jabref.model.util.DummyFileUpdateMonitor;
import org.jabref.preferences.JabRefPreferences;

Expand Down Expand Up @@ -93,14 +95,14 @@ public String write() throws Exception {
@Benchmark
public List<BibEntry> search() {
// FIXME: Reuse SearchWorker here
SearchQuery searchQuery = new SearchQuery("Journal Title 500", false, false);
SearchQuery searchQuery = new SearchQuery("Journal Title 500", EnumSet.noneOf(SearchFlags.class));
return database.getEntries().stream().filter(searchQuery::isMatch).collect(Collectors.toList());
}

@Benchmark
public List<BibEntry> parallelSearch() {
// FIXME: Reuse SearchWorker here
SearchQuery searchQuery = new SearchQuery("Journal Title 500", false, false);
SearchQuery searchQuery = new SearchQuery("Journal Title 500", EnumSet.noneOf(SearchFlags.class));
return database.getEntries().parallelStream().filter(searchQuery::isMatch).collect(Collectors.toList());
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@
requires flexmark.util.ast;
requires flexmark.util.data;
requires com.h2database.mvstore;
requires lucene.queryparser;
requires lucene.core;
requires lucene;
requires org.eclipse.jgit;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.dataformat.yaml;
requires com.fasterxml.jackson.datatype.jsr310;
requires net.harawata.appdirs;
}
3 changes: 1 addition & 2 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@ private boolean exportMatches(List<ParserResult> loaded) {
BibDatabase dataBase = pr.getDatabase();

SearchPreferences searchPreferences = Globals.prefs.getSearchPreferences();
SearchQuery query = new SearchQuery(searchTerm, searchPreferences.isCaseSensitive(),
searchPreferences.isRegularExpression());
SearchQuery query = new SearchQuery(searchTerm, searchPreferences.getSearchFlags());
List<BibEntry> matches = new DatabaseSearcher(query, dataBase).getMatches();

// export matches
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
import org.jabref.gui.push.PushToApplicationAction;
import org.jabref.gui.push.PushToApplicationsManager;
import org.jabref.gui.search.GlobalSearchBar;
import org.jabref.gui.search.RebuildFulltextSearchIndexAction;
import org.jabref.gui.shared.ConnectToSharedDatabaseCommand;
import org.jabref.gui.shared.PullChangesFromSharedAction;
import org.jabref.gui.slr.ExistingStudySearchAction;
Expand Down Expand Up @@ -819,7 +820,11 @@ private MenuBar createMenu() {
pushToApplicationMenuItem,
new SeparatorMenuItem(),
factory.createMenuItem(StandardActions.START_NEW_STUDY, new StartNewStudyAction(this, Globals.getFileUpdateMonitor(), Globals.TASK_EXECUTOR, prefs)),
factory.createMenuItem(StandardActions.SEARCH_FOR_EXISTING_STUDY, new ExistingStudySearchAction(this, Globals.getFileUpdateMonitor(), Globals.TASK_EXECUTOR, prefs))
factory.createMenuItem(StandardActions.SEARCH_FOR_EXISTING_STUDY, new ExistingStudySearchAction(this, Globals.getFileUpdateMonitor(), Globals.TASK_EXECUTOR, prefs)),

new SeparatorMenuItem(),

factory.createMenuItem(StandardActions.REBUILD_FULLTEXT_SEARCH_INDEX, new RebuildFulltextSearchIndexAction(stateManager, this::getCurrentLibraryTab, dialogService, prefs.getFilePreferences()))
);

SidePaneComponent webSearch = sidePaneManager.getComponent(SidePaneType.WEB_SEARCH);
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/jabref/gui/JabRefMain.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package org.jabref.gui;

import java.io.File;
import java.io.IOException;
import java.net.Authenticator;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;

import javafx.application.Application;
import javafx.application.Platform;
Expand All @@ -21,9 +27,11 @@
import org.jabref.logic.util.OS;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.pdf.search.SearchFieldConstants;
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreferencesService;

import net.harawata.appdirs.AppDirsFactory;
import org.apache.commons.cli.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -59,6 +67,8 @@ public void start(Stage mainStage) {

applyPreferences(preferences);

clearOldSearchIndices();

try {
// Process arguments
ArgumentProcessor argumentProcessor = new ArgumentProcessor(arguments, ArgumentProcessor.Mode.INITIAL_START);
Expand Down Expand Up @@ -139,4 +149,24 @@ private static void configureProxy(ProxyPreferences proxyPreferences) {
Authenticator.setDefault(new ProxyAuthenticator());
}
}

private static void clearOldSearchIndices() {
Path appData = Path.of(AppDirsFactory.getInstance().getUserDataDir("JabRef", null, "org.jabref"));
Path currentIndexPath = Path.of(AppDirsFactory.getInstance().getUserDataDir("JabRef", SearchFieldConstants.VERSION, "org.jabref"));

try (DirectoryStream<Path> stream = Files.newDirectoryStream(appData)) {
for (Path path : stream) {
if (Files.isDirectory(path) && !path.equals(currentIndexPath)) {
LOGGER.info("Deleting out-of-date fulltext search index at {}.", path);
Files.walk(path)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);

}
}
} catch (IOException e) {
LOGGER.error("Could not access app-directory at {}", appData, e);
}
}
}
71 changes: 71 additions & 0 deletions src/main/java/org/jabref/gui/LibraryTab.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -43,8 +44,11 @@
import org.jabref.logic.autosaveandbackup.BackupManager;
import org.jabref.logic.citationstyle.CitationStyleCache;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.importer.util.FileFieldParser;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.pdf.FileAnnotationCache;
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager;
import org.jabref.logic.pdf.search.indexing.PdfIndexer;
import org.jabref.logic.search.SearchQuery;
import org.jabref.logic.shared.DatabaseLocation;
import org.jabref.logic.util.UpdateField;
Expand All @@ -56,10 +60,13 @@
import org.jabref.model.database.event.EntriesAddedEvent;
import org.jabref.model.database.event.EntriesRemovedEvent;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
import org.jabref.model.entry.event.EntriesEventSource;
import org.jabref.model.entry.event.EntryChangedEvent;
import org.jabref.model.entry.event.FieldChangedEvent;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.field.StandardField;
import org.jabref.preferences.PreferencesService;

import com.google.common.eventbus.Subscribe;
Expand Down Expand Up @@ -101,6 +108,8 @@ public class LibraryTab extends Tab {
// initializing it so we prevent NullPointerException
private BackgroundTask<ParserResult> dataLoadingTask = BackgroundTask.wrap(() -> null);

private IndexingTaskManager indexingTaskManager = new IndexingTaskManager(Globals.TASK_EXECUTOR);

public LibraryTab(JabRefFrame frame,
PreferencesService preferencesService,
BibDatabaseContext bibDatabaseContext,
Expand All @@ -125,6 +134,7 @@ public LibraryTab(JabRefFrame frame,
setupAutoCompletion();

this.getDatabase().registerListener(new SearchListener());
this.getDatabase().registerListener(new IndexUpdateListener());
this.getDatabase().registerListener(new EntriesRemovedListener());

// ensure that at each addition of a new entry, the entry is added to the groups interface
Expand Down Expand Up @@ -332,6 +342,8 @@ public void updateTabTitle(boolean isChanged) {
textProperty().setValue(tabTitle.toString());
setTooltip(new Tooltip(toolTipText.toString()));
});

indexingTaskManager.updateDatabaseName(tabTitle.toString());
}

private List<String> collectAllDatabasePaths() {
Expand Down Expand Up @@ -846,4 +858,63 @@ public void listen(EntriesRemovedEvent removedEntriesEvent) {
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch());
}
}

private class IndexUpdateListener {

public IndexUpdateListener() {
try {
indexingTaskManager.addToIndex(PdfIndexer.of(bibDatabaseContext, preferencesService.getFilePreferences()), bibDatabaseContext);
} catch (IOException e) {
LOGGER.error("Cannot access lucene index", e);
}
}

@Subscribe
public void listen(EntriesAddedEvent addedEntryEvent) {
try {
PdfIndexer pdfIndexer = PdfIndexer.of(bibDatabaseContext, preferencesService.getFilePreferences());
for (BibEntry addedEntry : addedEntryEvent.getBibEntries()) {
indexingTaskManager.addToIndex(pdfIndexer, addedEntry, bibDatabaseContext);
}
} catch (IOException e) {
LOGGER.error("Cannot access lucene index", e);
}
}

@Subscribe
public void listen(EntriesRemovedEvent removedEntriesEvent) {
try {
PdfIndexer pdfIndexer = PdfIndexer.of(bibDatabaseContext, preferencesService.getFilePreferences());
for (BibEntry removedEntry : removedEntriesEvent.getBibEntries()) {
indexingTaskManager.removeFromIndex(pdfIndexer, removedEntry);
}
} catch (IOException e) {
LOGGER.error("Cannot access lucene index", e);
}
}

@Subscribe
public void listen(FieldChangedEvent fieldChangedEvent) {
if (fieldChangedEvent.getField().equals(StandardField.FILE)) {
List<LinkedFile> oldFileList = FileFieldParser.parse(fieldChangedEvent.getOldValue());
List<LinkedFile> newFileList = FileFieldParser.parse(fieldChangedEvent.getNewValue());

List<LinkedFile> addedFiles = new ArrayList<>(newFileList);
addedFiles.remove(oldFileList);
List<LinkedFile> removedFiles = new ArrayList<>(oldFileList);
removedFiles.remove(newFileList);

try {
indexingTaskManager.addToIndex(PdfIndexer.of(bibDatabaseContext, preferencesService.getFilePreferences()), fieldChangedEvent.getBibEntry(), addedFiles, bibDatabaseContext);
indexingTaskManager.removeFromIndex(PdfIndexer.of(bibDatabaseContext, preferencesService.getFilePreferences()), fieldChangedEvent.getBibEntry(), removedFiles);
} catch (IOException e) {
LOGGER.warn("I/O error when writing lucene index", e);
}
}
}
}

public IndexingTaskManager getIndexingTaskManager() {
return indexingTaskManager;
}
}
1 change: 1 addition & 0 deletions src/main/java/org/jabref/gui/actions/StandardActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum StandardActions implements Action {
DELETE(Localization.lang("Delete"), IconTheme.JabRefIcons.DELETE_ENTRY),
DELETE_ENTRY(Localization.lang("Delete Entry"), IconTheme.JabRefIcons.DELETE_ENTRY, KeyBinding.DELETE_ENTRY),
SEND_AS_EMAIL(Localization.lang("Send as email"), IconTheme.JabRefIcons.EMAIL),
REBUILD_FULLTEXT_SEARCH_INDEX(Localization.lang("Rebuild fulltext search index"), IconTheme.JabRefIcons.FILE),
OPEN_EXTERNAL_FILE(Localization.lang("Open file"), IconTheme.JabRefIcons.FILE, KeyBinding.OPEN_FILE),
OPEN_URL(Localization.lang("Open URL or DOI"), IconTheme.JabRefIcons.WWW, KeyBinding.OPEN_URL_OR_DOI),
SEARCH_SHORTSCIENCE(Localization.lang("Search ShortScience")),
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jabref.gui.StateManager;
import org.jabref.gui.citationkeypattern.GenerateCitationKeySingleAction;
import org.jabref.gui.entryeditor.fileannotationtab.FileAnnotationTab;
import org.jabref.gui.entryeditor.fileannotationtab.FulltextSearchResultsTab;
import org.jabref.gui.externalfiles.ExternalFilesEntryLinker;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.help.HelpAction;
Expand Down Expand Up @@ -267,6 +268,8 @@ private List<EntryEditorTab> createTabs() {
// LaTeX citations tab
entryEditorTabs.add(new LatexCitationsTab(databaseContext, preferencesService, taskExecutor, dialogService));

entryEditorTabs.add(new FulltextSearchResultsTab(stateManager, preferencesService.getTheme(), preferencesService.getFilePreferences()));

return entryEditorTabs;
}

Expand Down
Loading