BaseSearchQuery

abstract class BaseSearchQuery<S : BaseDocSource, T : BaseSearchQuery<S, T>>(docSourceFactory: (obj: Deserializer.ObjectCtx) -> S, query: QueryExpression? = null, params: Params = Params())

An abstract class that holds all the search query builder methods. Inheritors of the class can implement some shortcut methods. For instance SearchQuery.execute which can be suspendable or blocking.

Constructors

Link copied to clipboard
fun <S : BaseDocSource> BaseSearchQuery(docSourceFactory: (obj: Deserializer.ObjectCtx) -> S, query: QueryExpression? = null, params: Params = Params())

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun aggs(clear: SearchQuery.CLEAR): T

Clears the existing aggregations.

fun aggs(vararg aggregations: Pair<String, Aggregation<*>>): T
fun aggs(aggregations: Map<String, Aggregation<*>>): T

Adds aggregations to the existing query aggregations.

Link copied to clipboard
open fun beforeExecute()

Method is called before query execution. Can be overriden in subclasses of SearchQuery.

Link copied to clipboard
fun clone(): T

Clones this search query builder.

Link copied to clipboard

Clears current search query doc value fields.

fun docvalueFields(vararg fields: FieldFormat): T

Adds fields to the search query doc value fields list.

Link copied to clipboard
fun ext(clear: SearchQuery.CLEAR): T

Clears current search query extensions.

fun ext(vararg extensions: SearchExt): T
fun ext(extensions: List<SearchExt>): T

Adds extensions to the search query extensions list.

Link copied to clipboard

Clears current search query retrieval fields.

fun fields(vararg fields: FieldFormat): T
fun fields(fields: List<FieldFormat>): T

Adds fields to the search query retrieval fields list.

Link copied to clipboard

Clears the existing filters.

fun filter(vararg filters: QueryExpression): T

Combines all the filter expressions together and wraps the existing query using the dev.evo.elasticmagic.query.Bool query expression.

fun filter(filters: List<QueryExpression>): T
Link copied to clipboard
fun from(from: Int?): T

Sets a number of hits to skip in a search result.

Link copied to clipboard

Clears the existing post filters.

fun postFilter(vararg filters: QueryExpression): T

Filter expressions in the post filter will be applied after the aggregations are calculated. Useful for building faceted filtering.

Link copied to clipboard
fun prepareCount(params: Params? = null): SearchQuery.Count
Link copied to clipboard
Link copied to clipboard
fun prepareSearch(params: Params? = null): SearchQuery.Search<S>

Makes an immutable view of the search query. Be careful when using this method.

Link copied to clipboard
fun prepareUpdate(script: Script? = null, params: Params? = null): SearchQuery.Update
Link copied to clipboard
fun query(query: QueryExpression?): T

Replaces main query expression.

Link copied to clipboard
inline fun <N : QueryExpression> queryNode(handle: NodeHandle<N>, block: (N) -> N): T

Allows to replace a specific query expression node using a handle of the node.

Link copied to clipboard
fun requestCache(requestCache: Boolean?): T

Enables/disables a request cache of the search query.

Link copied to clipboard

Clears the existing rescorers.

fun rescore(vararg rescores: Rescore): T

Adds rescores to the existing query rescorers. Rescoring is executed after post filter phase.

fun rescore(rescores: List<Rescore>): T
Link copied to clipboard
fun routing(routing: Long?): T

Sets a routing parameter of the search query. A search request will be send to a specific shard.

fun routing(routing: String?): T

Updates search type of the search query.

Link copied to clipboard

Clears current search query runtime fields.

fun runtimeMappings(vararg fields: BoundRuntimeField<*>): T

Adds fields to the search query runtime fields list.

Link copied to clipboard

Clears current search query stored fields.

fun scriptFields(vararg fields: Pair<String, Script>): T
fun scriptFields(fields: Map<String, Script>): T

Adds fields to the search query script fields list.

Link copied to clipboard
fun searchParams(vararg params: Pair<String, Any?>): T
fun searchParams(params: Map<String, Any?>): T

Updates search parameters.

Link copied to clipboard
fun searchType(searchType: SearchType?): T

Updates search type of the search query.

Link copied to clipboard
fun seqNoPrimaryTerm(seqNoPrimaryTerm: Boolean?): T

Specifies if a sequence number and a primary term should be returned within a hit.

Link copied to clipboard
fun size(size: Int?): T

Sets a maximum number of hits in a search result.

Link copied to clipboard
fun sort(clear: SearchQuery.CLEAR): T

Clears the existing sorts.

fun sort(vararg sorts: Sort): T

Adds sorts to the existing query sorting expressions.

fun sort(sorts: List<Sort>): T

Adds sorts from a list to the existing query sorting expressions.

Link copied to clipboard

Clears source filtering values that were previously set.

fun source(vararg includes: FieldOperations<*>): T

Adds includes field lists to the document source fields filtering.

fun source(enable: Boolean): T

Disables or enables document's source filtering.

fun source(includes: List<FieldOperations<*>> = emptyList(), excludes: List<FieldOperations<*>> = emptyList()): T

Adds includes and excludes field lists to the document source fields filtering.

Link copied to clipboard
fun stats(tag: String?): T

Marks the search query with a tag so it is possible to collect search query statistics by tags.

Link copied to clipboard

Clears current search query stored fields.

fun storedFields(vararg fields: FieldOperations<*>): T

Adds fields to the search query stored fields list.

Link copied to clipboard
fun terminateAfter(terminateAfter: Int?): T

Sets a maximum number of matched documents per shard after which the query should be terminated.

Link copied to clipboard
fun trackScores(trackScores: Boolean?): T

If trackScores is true forces computing scores even when sorting on a field.

Link copied to clipboard
fun trackTotalHits(trackTotalHits: Boolean?): T

When trackTotalHits is true the search query will always count the total number of hits that match the query.

Link copied to clipboard
fun version(version: Boolean?): T

Enables/disables a document version to be returned within a hit.

Inheritors

Link copied to clipboard