Skip to content

Commit

Permalink
Add type-safe query API
Browse files Browse the repository at this point in the history
  • Loading branch information
mvelimir committed Jan 10, 2023
1 parent 0fa46bd commit 9d32aa1
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,26 @@ object ElasticQuery {
def toJson(implicit EP: ElasticPrimitive[A]): Json = EP.toJson(value)
}

def matches[S, A: ElasticPrimitive](field: Selection[S, A], value: A): ElasticQuery[Match] =
MatchQuery(field.toString, value)

def matches[A: ElasticPrimitive](field: String, value: A): ElasticQuery[Match] =
MatchQuery(field, value)

def boolQuery(): BoolQuery = BoolQuery.empty

def exists(field: Selection[_, _]): ElasticQuery[Exists] = ExistsQuery(field.toString)

def exists(field: String): ElasticQuery[Exists] = ExistsQuery(field)

def matchAll(): ElasticQuery[MatchAll] = MatchAllQuery()

def range(field: Selection[_, _]): RangeQuery[Unbounded.type, Unbounded.type] = RangeQuery.empty(field.toString)

def range(field: String): RangeQuery[Unbounded.type, Unbounded.type] = RangeQuery.empty(field)

def term[S, A: ElasticPrimitive](field: Selection[S, A], value: A): ElasticQuery[Term[A]] = TermQuery(field.toString, value)

def term[A: ElasticPrimitive](field: String, value: A): ElasticQuery[Term[A]] = TermQuery(field, value)

private[elasticsearch] final case class BoolQuery(must: List[ElasticQuery[_]], should: List[ElasticQuery[_]])
Expand Down

0 comments on commit 9d32aa1

Please sign in to comment.