Update config

This commit is contained in:
2021-04-12 21:13:49 +02:00
parent 204ae7988e
commit 7ad8b7039b
21 changed files with 138 additions and 217 deletions
+8 -11
View File
@@ -7,18 +7,15 @@ import org.apache.lucene.document.Field
import org.apache.lucene.document.StringField
import org.apache.lucene.document.TextField
internal fun PersistedNote.toDocument(): Document {
val note = this
return Document().apply {
// non searchable fields
add(StringField(uuidField, UuidFieldConverter.toDoc(note.uuid), Field.Store.YES))
add(StringField(updatedAtField, LocalDateTimeFieldConverter.toDoc(note.updatedAt), Field.Store.YES))
internal fun PersistedNote.toDocument() = Document().apply {
// non searchable fields
add(StringField(uuidField, UuidFieldConverter.toDoc(uuid), Field.Store.YES))
add(StringField(updatedAtField, LocalDateTimeFieldConverter.toDoc(updatedAt), Field.Store.YES))
// searchable fields
add(TextField(titleField, note.meta.title, Field.Store.YES))
add(TextField(tagsField, TagsFieldConverter.toDoc(note.meta.tags), Field.Store.YES))
add(TextField(contentField, note.markdown, Field.Store.YES))
}
// searchable fields
add(TextField(titleField, title, Field.Store.YES))
add(TextField(tagsField, TagsFieldConverter.toDoc(tags), Field.Store.YES))
add(TextField(contentField, markdown, Field.Store.YES))
}
internal fun Document.toNoteMeta() = PersistedNoteMetadata(
+1 -6
View File
@@ -16,12 +16,7 @@ import javax.inject.Named
import javax.inject.Singleton
@Singleton
internal class NoteSearcherImpl(
@Named("search-index")
basePath: Path,
) : NoteSearcher {
constructor() : this(Path.of("/tmp", "lucene"))
internal class NoteSearcherImpl(@Named("search-index") basePath: Path) : NoteSearcher {
private val baseFile = basePath.toFile()
+2 -1
View File
@@ -1,5 +1,6 @@
package be.simplenotes.search
import be.simplenotes.config.DataConfig
import io.micronaut.context.annotation.Factory
import io.micronaut.context.annotation.Prototype
import java.nio.file.Path
@@ -10,5 +11,5 @@ class SearchModule {
@Named("search-index")
@Prototype
internal fun luceneIndex() = Path.of(".lucene")
internal fun luceneIndex(dataConfig: DataConfig) = Path.of(dataConfig.dataDir).resolve("index")
}