jillesvangurp/kt-search

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

Closed this issue · 1 comments

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)
    }

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.