-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
267 additions
and
48 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
modules/library/src/main/scala/zio/elasticsearch/Boost.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package zio.elasticsearch | ||
|
||
import zio.elasticsearch.ElasticQuery.{ElasticPrimitive, MatchAllQuery, TermQuery} | ||
import zio.elasticsearch.ElasticQueryType.{MatchAll, Term} | ||
|
||
object Boost { | ||
|
||
trait WithBoost[EQT <: ElasticQueryType] { | ||
def withBoost(query: ElasticQuery[EQT], value: Double): ElasticQuery[EQT] | ||
} | ||
|
||
object WithBoost { | ||
implicit val matchAllWithBoost: WithBoost[MatchAll] = (query: ElasticQuery[MatchAll], value: Double) => | ||
query match { | ||
case q: MatchAllQuery => q.copy(boost = Some(value)) | ||
} | ||
|
||
implicit def termWithBoost[A: ElasticPrimitive]: WithBoost[Term[A]] = | ||
(query: ElasticQuery[Term[A]], value: Double) => | ||
query match { | ||
case q: TermQuery[A] => q.copy(boost = Some(value)) | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/library/src/main/scala/zio/elasticsearch/CaseInsensitive.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package zio.elasticsearch | ||
|
||
import zio.elasticsearch.ElasticQuery.TermQuery | ||
import zio.elasticsearch.ElasticQueryType.Term | ||
|
||
object CaseInsensitive { | ||
|
||
trait WithCaseInsensitive[EQT <: ElasticQueryType] { | ||
def withCaseInsensitive(query: ElasticQuery[EQT], value: Boolean): ElasticQuery[EQT] | ||
} | ||
|
||
object WithCaseInsensitive { | ||
implicit val termWithCaseInsensitiveString: WithCaseInsensitive[Term[String]] = | ||
(query: ElasticQuery[Term[String]], value: Boolean) => | ||
query match { | ||
case q: TermQuery[String] => q.copy(caseInsensitive = Some(value)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.