我正在尝试从弹性搜索回购中检索记录。我的方法看起来像这样
def findPartialFieldWithId(id: String, path: String): Future[SearchResponse] = {
client.execute {
search in IndexType query {
termQuery("_id", id)
} sourceInclude (path)
}
}
但如果id
是String而不是String的列表,我应该使用什么DSL?
尝试阅读elastic4s文档和测试用例,但仍无法使其正常工作
答案 0 :(得分:1)
termsQuery
是要走的路:
def findPartialFieldWithId(ids: Seq[String], path: String): Future[SearchResponse] = {
import scala.collection.JavaConverters._
client.execute {
search in IndexType query {
termsQuery("_id", ids: _* )
} sourceInclude (path)
}
}