Skip to content

Conversation

@LoayGhreeb
Copy link
Member

@LoayGhreeb LoayGhreeb commented Sep 7, 2024

Follow-up to: #11542
Update the Lucene version. If any changes to the index require reindexing (e.g., new/removed/renamed fields, analyzer changes), this version number should be updated.
Changing the version will change the index path:

public Path getFulltextIndexBaseDirectory() {
return Path.of(AppDirsFactory.getInstance()
.getUserDataDir(OS.APP_DIR_APP_NAME,
"lucene" + File.separator + SearchFieldConstants.VERSION,
OS.APP_DIR_APP_AUTHOR));
}

The old index will be removed
private static void clearOldSearchIndices() {
Path currentIndexPath = OS.getNativeDesktop().getFulltextIndexBaseDirectory();
Path appData = currentIndexPath.getParent();
try {
Files.createDirectories(currentIndexPath);
} catch (IOException e) {
LOGGER.error("Could not create index directory {}", appData, e);
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(appData)) {
for (Path path : stream) {
if (Files.isDirectory(path) && !path.toString().endsWith("ssl") && path.toString().contains("lucene")
&& !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) {

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

koppor
koppor previously requested changes Sep 7, 2024
* 2. Lucene codec changes (see module-info.java Lucene section)
* Incrementing triggers reindexing.
*/
VERSION("1.0"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, just number is OK.

Alternative: 6.0.0 - to mirror the JabRef main version and the last number is the index version within a role. However since new JabRef versions come out and need no full rebuild, just 1 is good.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2024

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

@Siedlerchr Siedlerchr enabled auto-merge September 7, 2024 17:49
@Siedlerchr Siedlerchr added this pull request to the merge queue Sep 7, 2024
Merged via the queue into main with commit 121eb9b Sep 7, 2024
@Siedlerchr Siedlerchr deleted the fix-version branch September 7, 2024 18:12
leaf-soba pushed a commit to leaf-soba/jabref that referenced this pull request Sep 11, 2024
* Update lucene version

* Change version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants