mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
create a single index writer for Lucene + Closes #231
This commit is contained in:
parent
b265b8b1e0
commit
748659e78e
@ -62,6 +62,11 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
*/
|
||||
private DirectoryReader directoryReader;
|
||||
|
||||
/**
|
||||
* Index writer.
|
||||
*/
|
||||
private IndexWriter indexWriter;
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
// Embedded Lucene can always start
|
||||
@ -84,6 +89,12 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
directory = new SimpleFSDirectory(luceneDirectory, NoLockFactory.INSTANCE);
|
||||
}
|
||||
|
||||
// Create an index writer
|
||||
IndexWriterConfig config = new IndexWriterConfig(new StandardAnalyzer());
|
||||
config.setCommitOnClose(true);
|
||||
config.setMergeScheduler(new SerialMergeScheduler());
|
||||
indexWriter = new IndexWriter(directory, config);
|
||||
|
||||
// Check index version and rebuild it if necessary
|
||||
if (DirectoryReader.indexExists(directory)) {
|
||||
log.info("Checking index health and version");
|
||||
@ -111,6 +122,13 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
log.error("Error closing the index reader", e);
|
||||
}
|
||||
}
|
||||
if (indexWriter != null) {
|
||||
try {
|
||||
indexWriter.close();
|
||||
} catch (IOException e) {
|
||||
log.error("Error closing the index writer, index may be corrupt", e);
|
||||
}
|
||||
}
|
||||
if (directory != null) {
|
||||
try {
|
||||
directory.close();
|
||||
@ -469,42 +487,16 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
||||
* @param runnable Runnable
|
||||
*/
|
||||
private void handle(LuceneRunnable runnable) {
|
||||
// Standard analyzer
|
||||
IndexWriterConfig config = new IndexWriterConfig(new StandardAnalyzer());
|
||||
|
||||
// Automatically commit when closing this writer
|
||||
config.setCommitOnClose(true);
|
||||
|
||||
// Merge sequentially, because Lucene writing is already done asynchronously
|
||||
config.setMergeScheduler(new SerialMergeScheduler());
|
||||
|
||||
// Creating index writer
|
||||
IndexWriter indexWriter = null;
|
||||
try {
|
||||
indexWriter = new IndexWriter(directory, config);
|
||||
} catch (IOException e) {
|
||||
log.error("Cannot create IndexWriter", e);
|
||||
}
|
||||
|
||||
try {
|
||||
runnable.run(indexWriter);
|
||||
} catch (Exception e) {
|
||||
log.error("Error in running index writing transaction", e);
|
||||
try {
|
||||
if (indexWriter != null) {
|
||||
indexWriter.rollback();
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
log.error("Cannot rollback index writing transaction", e1);
|
||||
}
|
||||
log.error("Error in running index writing", e);
|
||||
}
|
||||
|
||||
try {
|
||||
if (indexWriter != null) {
|
||||
indexWriter.close();
|
||||
}
|
||||
indexWriter.commit();
|
||||
} catch (IOException e) {
|
||||
log.error("Cannot commit and close IndexWriter", e);
|
||||
log.error("Cannot commit index writer", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@ angular.module('docs').controller('DocumentViewContent', function ($scope, $root
|
||||
forceHelperSize: true,
|
||||
forcePlaceholderSize: true,
|
||||
tolerance: 'pointer',
|
||||
handle: '.handle',
|
||||
stop: function () {
|
||||
// Send new positions to server
|
||||
$scope.$apply(function () {
|
||||
|
@ -13,10 +13,10 @@
|
||||
<img ng-src="../api/file/{{ file.id }}/data?size=thumb" uib-tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
|
||||
</a>
|
||||
<div class="file-info">
|
||||
<div class="v-align caption caption-hover-inverse file-name" ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
|
||||
<div class="caption caption-hover">
|
||||
<div class="v-align">
|
||||
<button class="btn btn-danger" ng-click="deleteFile($event, file)"><span class="fas fa-trash"></span></button>
|
||||
</div>
|
||||
<div class="v-align file-name" ng-if="file.name">{{ file.name }}</div>
|
||||
<div class="v-align">
|
||||
<input type="checkbox" ng-model="file.checked" />
|
||||
</div>
|
||||
|
@ -55,12 +55,8 @@
|
||||
</a>
|
||||
|
||||
<div class="file-info">
|
||||
<div class="v-align caption file-name" ng-class="{ 'caption-hover-inverse': document.writable }"
|
||||
ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
|
||||
<div class="caption caption-hover" ng-show="document.writable">
|
||||
<div class="btn btn-default handle"><span class="fas fa-arrows-alt-h"></span></div>
|
||||
</div>
|
||||
|
||||
<div></div><!-- Actually useful -->
|
||||
<div class="v-align file-name" ng-if="file.name">{{ file.name }}</div>
|
||||
<div class="v-align" ng-show="document.writable">
|
||||
<div uib-dropdown>
|
||||
<button class="btn btn-default" uib-dropdown-toggle>
|
||||
|
@ -203,31 +203,22 @@ ul.tag-tree {
|
||||
}
|
||||
|
||||
.file-name {
|
||||
overflow: hidden;
|
||||
word-wrap: break-word;
|
||||
white-space: normal;
|
||||
display: block;
|
||||
text-overflow: ellipsis;
|
||||
margin-right: auto !important;
|
||||
margin-left: auto !important;
|
||||
}
|
||||
|
||||
.file-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.caption {
|
||||
.v-align {
|
||||
height: 42px;
|
||||
padding: 0;
|
||||
margin: 9px;
|
||||
}
|
||||
|
||||
.v-align {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
> * {
|
||||
margin-right: 8px;
|
||||
}
|
||||
margin: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,26 +233,6 @@ ul.tag-tree {
|
||||
margin-top: 100px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.caption-hover {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.caption-hover-inverse {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.caption-hover {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.caption-hover-inverse {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Permissions table
|
||||
|
Loading…
Reference in New Issue
Block a user