jillesvangurp / kt-search

Multi platform kotlin client for Elasticsearch & Opensearch with easily extendable Kotlin DSLs for queries, mappings, bulk, and more.
MIT License
95 stars 23 forks source link

[FEAT] adding routing argument for IndexRepository.search() and deleteByQuery() #73

Closed minkyu725 closed 11 months ago

minkyu725 commented 1 year ago

Describe the enhancement

IndexRepository.search() and deleteByQuery() methods allow routing argument

Why is this needed?

I prefer using IndexRepository to using SearchClient directly. But when I have to query with routing parameter, it is inevitable to use SearchClient.

How do you think it should be done?

IndexRepository.search() and deleteByQuery() methods allow routing argument to be passed to internal SearchClient.

Will you be able to help with a pull request?

If you grant me permission to create new branch, I can make PR for this issue. or you just can modify it referencing below.

    // IndexRepository.kt
    suspend fun search(rawJson: String, routing: String? = null): SearchResponse {
        return client.search(target = indexReadAlias, rawJson = rawJson, routing = routing)
    }

    suspend fun search(dsl: SearchDSL, routing: String? = null): SearchResponse {
        return client.search(target = indexReadAlias, dsl = dsl, routing = routing)
    }

    suspend fun search(routing: String? = null, block: SearchDSL.() -> Unit): SearchResponse {
        return client.search(target = indexReadAlias, block = block, routing = routing)
    }

    suspend fun deleteByQuery(routing: String? = null, block: SearchDSL.() -> Unit): DeleteByQueryResponse {
        return client.deleteByQuery(target = indexWriteAlias, block = block, routing = routing)
    }
jillesvangurp commented 1 year ago

Thanks for reporting. I think the issue is bigger here and there may be all sorts of parameters that we need to support here.

The usual process for PRs is that you fork and create your branch there and then create a pull request from that.