All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.zakadabar.lib.lucene.data.LuceneQuery.kt Maven / Gradle / Ivy

There is a newer version: 2023.4.20
Show newest version
/*
 * Copyright © 2020-2021, Simplexion, Hungary and contributors. Use of this source code is governed by the Apache 2.0 license.
 */
package zakadabar.lib.lucene.data

import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.ListSerializer
import zakadabar.core.authorize.Executor
import zakadabar.core.comm.CommConfig
import zakadabar.core.data.QueryBo
import zakadabar.core.data.QueryBoCompanion
import zakadabar.core.schema.BoSchema


/**
 * Perform a search with Lucene.
 */
@Serializable
class LuceneQuery(

    var field: String = "contents",
    var query: String = "",
    var hitsPerPage: Int = 10,
    var knnVectors : Int = 0

) : QueryBo> {

    companion object : QueryBoCompanion(luceneBasic)

    override suspend fun execute(executor: Executor?, callConfig: CommConfig?): List =
        comm.query(this, serializer(), ListSerializer(LuceneQueryResult.serializer()), executor, callConfig)

    override fun schema() = BoSchema {
        + ::field max 100
        + ::query blank false
        + ::hitsPerPage
        + ::knnVectors
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy