mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +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;
|
private DirectoryReader directoryReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index writer.
|
||||||
|
*/
|
||||||
|
private IndexWriter indexWriter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept() {
|
public boolean accept() {
|
||||||
// Embedded Lucene can always start
|
// Embedded Lucene can always start
|
||||||
@ -84,6 +89,12 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
|||||||
directory = new SimpleFSDirectory(luceneDirectory, NoLockFactory.INSTANCE);
|
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
|
// Check index version and rebuild it if necessary
|
||||||
if (DirectoryReader.indexExists(directory)) {
|
if (DirectoryReader.indexExists(directory)) {
|
||||||
log.info("Checking index health and version");
|
log.info("Checking index health and version");
|
||||||
@ -111,6 +122,13 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
|||||||
log.error("Error closing the index reader", e);
|
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) {
|
if (directory != null) {
|
||||||
try {
|
try {
|
||||||
directory.close();
|
directory.close();
|
||||||
@ -469,42 +487,16 @@ public class LuceneIndexingHandler implements IndexingHandler {
|
|||||||
* @param runnable Runnable
|
* @param runnable Runnable
|
||||||
*/
|
*/
|
||||||
private void handle(LuceneRunnable 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 {
|
try {
|
||||||
runnable.run(indexWriter);
|
runnable.run(indexWriter);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error in running index writing transaction", e);
|
log.error("Error in running index writing", e);
|
||||||
try {
|
|
||||||
if (indexWriter != null) {
|
|
||||||
indexWriter.rollback();
|
|
||||||
}
|
|
||||||
} catch (IOException e1) {
|
|
||||||
log.error("Cannot rollback index writing transaction", e1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (indexWriter != null) {
|
indexWriter.commit();
|
||||||
indexWriter.close();
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} 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,
|
forceHelperSize: true,
|
||||||
forcePlaceholderSize: true,
|
forcePlaceholderSize: true,
|
||||||
tolerance: 'pointer',
|
tolerance: 'pointer',
|
||||||
handle: '.handle',
|
|
||||||
stop: function () {
|
stop: function () {
|
||||||
// Send new positions to server
|
// Send new positions to server
|
||||||
$scope.$apply(function () {
|
$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" />
|
<img ng-src="../api/file/{{ file.id }}/data?size=thumb" uib-tooltip="{{ file.mimetype }} | {{ file.size | filesize }}" tooltip-placement="top" />
|
||||||
</a>
|
</a>
|
||||||
<div class="file-info">
|
<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="v-align">
|
||||||
<div class="caption caption-hover">
|
|
||||||
<button class="btn btn-danger" ng-click="deleteFile($event, file)"><span class="fas fa-trash"></span></button>
|
<button class="btn btn-danger" ng-click="deleteFile($event, file)"><span class="fas fa-trash"></span></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="v-align file-name" ng-if="file.name">{{ file.name }}</div>
|
||||||
<div class="v-align">
|
<div class="v-align">
|
||||||
<input type="checkbox" ng-model="file.checked" />
|
<input type="checkbox" ng-model="file.checked" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,12 +55,8 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="file-info">
|
<div class="file-info">
|
||||||
<div class="v-align caption file-name" ng-class="{ 'caption-hover-inverse': document.writable }"
|
<div></div><!-- Actually useful -->
|
||||||
ng-click="openFile(file)" ng-if="file.name">{{ file.name }}</div>
|
<div class="v-align file-name" 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 class="v-align" ng-show="document.writable">
|
<div class="v-align" ng-show="document.writable">
|
||||||
<div uib-dropdown>
|
<div uib-dropdown>
|
||||||
<button class="btn btn-default" uib-dropdown-toggle>
|
<button class="btn btn-default" uib-dropdown-toggle>
|
||||||
|
@ -203,31 +203,22 @@ ul.tag-tree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.file-name {
|
.file-name {
|
||||||
|
overflow: hidden;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
white-space: normal;
|
white-space: normal;
|
||||||
display: block;
|
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
margin-right: auto !important;
|
|
||||||
margin-left: auto !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.file-info {
|
.file-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
||||||
.caption {
|
.v-align {
|
||||||
height: 42px;
|
height: 42px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 9px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.v-align {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin: 4px;
|
||||||
> * {
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,26 +233,6 @@ ul.tag-tree {
|
|||||||
margin-top: 100px;
|
margin-top: 100px;
|
||||||
transform: translateY(-50%);
|
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
|
// Permissions table
|
||||||
|
Loading…
Reference in New Issue
Block a user