在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mbuhot/eskotlin开源软件地址(OpenSource Url):https://github.com/mbuhot/eskotlin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):ES KotlinElasticsearch Query DSL for Kotlin. This library aims to minimize the gap between the Elasticsearch JSON query DSL, and the API used when writing kotlin applications. This integrates with the existing java API, only providing a nicer syntax to build the queries. Getting StartedGradlerepositories {
mavenCentral()
...
maven {
url "http://dl.bintray.com/mbuhot/maven"
}
}
dependencies {
compile 'mbuhot:eskotlin:0.7.0'
...
} See CHANGELOG for older versions supporting previous elasticsearch client versions. MavenFull details on bintray <dependency>
<groupId>mbuhot</groupId>
<artifactId>eskotlin</artifactId>
<version>0.7.0</version>
<type>pom</type>
</dependency> ExamplesTerm QueryJSON: {
"term" : { "user" : "Kimchy" }
} Kotlin: val query = term {
"user" to "Kimchy"
} Bool QueryJSON: {
"bool" : {
"must" : {
"term" : { "user" : "kimchy" }
},
"filter": {
"term" : { "tag" : "tech" }
},
"must_not" : {
"range" : {
"age" : { "from" : 10, "to" : 20 }
}
},
"should" : [
{
"term" : { "tag" : "wow" }
},
{
"term" : { "tag" : "elasticsearch" }
}
],
"minimum_should_match" : 1,
"boost" : 1.0
}
} Kotlin: val query = bool {
must {
term { "user" to "kimchy" }
}
filter {
term { "tag" to "tech" }
}
must_not {
range {
"age" {
from = 10
to = 20
}
}
}
should = listOf(
term { "tag" to "wow" },
term { "tag" to "elasticsearch" })
minimum_should_match = 1
boost = 1.0f
}
Function Score QueryJSON: {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"filter": {
"term": {
"foo": "bar"
}
},
"gauss": {
"baz": {
"scale": 1.0
}
}
},
{
"filter": {
"match_all": {}
},
"random_score": {
"seed": 234
}
},
{
"exp": {
"qux": {
"scale": 2.3
}
}
}
],
"score_mode": "max",
"boost_mode": "multiply",
"max_boost": 5.0,
"boost": 1.2,
"min_score": 0.001
}
} Kotlin: val query = function_score {
query = match_all { }
functions = listOf(
term { "foo" to "bar" } to gaussDecayFunction("baz", 1.0),
match_all { } to randomFunction(234L),
null to exponentialDecayFunction("qux", 2.3))
boost = 1.2f
boost_mode = "multiply"
score_mode = "max"
max_boost = 5.0f
min_score = 0.001f
} See the src/test directory for more examples. API CoverageFull Text Queries - DoneTerm Queries - DoneCompound Queries - DoneJoining Queries - DoneGeo Queries - Contributions welcome!
Specialized Queries - Contributions welcome!
Span Queries - Contributions welcome!
Aggregations - Contributions welcome!LicenseMIT - See LICENSE file for full text. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论