私はelasticsearchのscalaとelastic4sで遊んで学んでいます。
公式のelasticsearchモジュールを使用するpythonスクリプトがあります。Python での私のコードは次のようになります。
res=helpers.scan(es, query={"_source": ["http_uri", "header_user_agent"],"query": {"query_string": {"query": "message:key"}}}, index="")
上記のpythonコードは機能します。900k の結果が得られ、それらを処理します。
基本的な scala コードを使用して e4s を試しています。これは単純なクエリです。私のクエリは間違っていますか?
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
object Banana {
def main(args: Array[String]) {
val client = ElasticClient.local
val res = client execute { search in "*" query "apiKey" } await
println(res.getHits.totalHits)
println(res)
}
}
これを実行した結果:
info] Running Banana
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
0
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 0,
"successful" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : 0.0,
"hits" : [ ]
}
}
そして、curl クエリによる応答:
$ curl -s 'localhost:9200/_search?q=apiKey&pretty=true' | head -12
{
"took" : 21,
"timed_out" : false,
"_shards" : {
"total" : 1200,
"successful" : 1200,
"failed" : 0
},
"hits" : {
"total" : 756253,
"max_score" : 1.5905869,
"hits" : [ {