Skip to content

Commit

Permalink
work around deprecation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jillesvangurp committed Jan 23, 2020
1 parent 0367d12 commit 169551a
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import org.elasticsearch.common.xcontent.DeprecationHandler
import org.elasticsearch.common.xcontent.NamedXContentRegistry
import org.elasticsearch.common.xcontent.XContentFactory
import org.elasticsearch.common.xcontent.XContentType
import org.elasticsearch.index.query.QueryBuilder
import org.elasticsearch.index.query.QueryBuilders
import org.elasticsearch.search.SearchModule
import org.elasticsearch.search.builder.SearchSourceBuilder

Expand Down Expand Up @@ -53,7 +55,7 @@ fun CountRequest.source(json: String, deprecationHandler: DeprecationHandler = L
deprecationHandler,
json
).use {
source(SearchSourceBuilder.fromXContent(it))
query(SearchSourceBuilder.fromXContent(it).query())
}
}

Expand Down Expand Up @@ -81,7 +83,7 @@ fun CountRequest.source(reader: Reader, deprecationHandler: DeprecationHandler =
deprecationHandler,
reader
).use {
source(SearchSourceBuilder.fromXContent(it))
query(SearchSourceBuilder.fromXContent(it).query())
}
}

Expand Down Expand Up @@ -119,13 +121,13 @@ fun CountRequest.source(
deprecationHandler,
inputStream
).use {
source(SearchSourceBuilder.fromXContent(it))
query(SearchSourceBuilder.fromXContent(it).query())
}
}

fun CountRequest.source(block: SearchSourceBuilder.()->Unit) {
val builder = SearchSourceBuilder()
block.invoke(builder)
source(builder)
query(builder.query())
}

0 comments on commit 169551a

Please sign in to comment.