diff --git a/backend/src/main/kotlin/com/storyteller_f/index/LuceneTopicSearchService.kt b/backend/src/main/kotlin/com/storyteller_f/index/LuceneTopicSearchService.kt index 028cb2f..8e850d3 100644 --- a/backend/src/main/kotlin/com/storyteller_f/index/LuceneTopicSearchService.kt +++ b/backend/src/main/kotlin/com/storyteller_f/index/LuceneTopicSearchService.kt @@ -106,27 +106,32 @@ class LuceneTopicSearchService(private val path: Path) : TopicSearchService { parent: Pair? ): Result> { return useLucene { - DirectoryReader.open(it).use { reader -> - val searcher = IndexSearcher(reader) - val combinedQuery = buildQuery(nextTopicId, word, root, parent) - Napier.i { - "lucene search query $combinedQuery" - } - val sortById = Sort(SortField("id2", SortField.Type.LONG, true)) - val docs = searcher.search(combinedQuery.build(), size, sortById) - val scoreDocs = docs.scoreDocs - PaginationResult(scoreDocs.mapNotNull { doc -> - searcher.storedFields().document(doc.doc)?.let { document -> - val content = document.get("content") - val id = document.get("id1").toPrimaryKeyOrNull() - if (content != null && id != null) { - restoreDocument(id, document) - } else { - null - } + try { + DirectoryReader.open(it).use { reader -> + val searcher = IndexSearcher(reader) + val combinedQuery = buildQuery(nextTopicId, word, root, parent) + Napier.i { + "lucene search query $combinedQuery" } - }, docs.totalHits.value) + val sortById = Sort(SortField("id2", SortField.Type.LONG, true)) + val docs = searcher.search(combinedQuery.build(), size, sortById) + val scoreDocs = docs.scoreDocs + PaginationResult(scoreDocs.mapNotNull { doc -> + searcher.storedFields().document(doc.doc)?.let { document -> + val content = document.get("content") + val id = document.get("id1").toPrimaryKeyOrNull() + if (content != null && id != null) { + restoreDocument(id, document) + } else { + null + } + } + }, docs.totalHits.value) + } + } catch (e: IndexNotFoundException) { + PaginationResult(emptyList(), 0) } + } } diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 43b4aed..b5ed67e 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -73,7 +73,7 @@ services: - INTERCEPTED_ERROR_CODES= - REVERSE_PROXY_WS=yes - REVERSE_PROXY_INTERCEPT_ERRORS=no - - USE_BAD_BEHAVIOR=no + - USE_BAD_BEHAVIOR=yes - BAD_BEHAVIOR_STATUS_CODES=400 403 404 405 429 444 - USE_MODSECURITY_CRS=no networks: