Reputation: 880
I am new to scala, using alpakka-elasticsearch client to perform query with elastic search.
Single search query is working fine with below two ways which internally calls to _search url of elastic search:
val writeCustomIndex = ElasticsearchSource
.typed[Book](
indexName = "source",
typeName = "_doc",
query = """{"match_all": {}}"""
)
OR
val readWithSearchParameters = ElasticsearchSource
.typed[TestDoc](
indexName,
Some(typeName),
searchParams = Map(
"query" -> """ {"match_all": {}} """,
"_source" -> """ ["id", "a", "c"] """
)
What I am looking for is to perform below multi query(_msearch) with this client.
url - http://localhost:9200/index1/_msearch?
request :
[
{"query" : {"match_all" : {}}, "from" : 0, "size" : 1},
{"index" : "index2"},
{"query" : {"match_all" : {}}, "from" : 0, "size" : 2}
]
elastic client source : https://doc.akka.io/docs/alpakka/current/elasticsearch.html
Upvotes: 3
Views: 225
Reputation: 880
Have tried with one approach as per suggestion, where I have merged two sources.
Hope, this may help someone!
var elasticRecord: Future[Seq[ElasticRecord]] = ElasticsearchSource
.typed[ElasticRecord](
indexName1,
Some(typeName1),
query1,
settings = ElasticsearchSourceSettings()).map { message =>
message.source
}.merge(ElasticsearchSource
.typed[ElasticRecord](
indexName2,
Some(typeName2),
query1,
settings = ElasticsearchSourceSettings()).map { message =>
message.source
}).runWith(Sink.seq)
Upvotes: 1