elastic4s查询带有密钥列表的文档

时间:2015-06-02 09:03:21

标签: elastic4s

我正在尝试从弹性搜索回购中检索记录。我的方法看起来像这样

def findPartialFieldWithId(id: String, path: String): Future[SearchResponse] = {
client.execute {
    search in IndexType query {
    termQuery("_id", id)
    } sourceInclude (path)
}

}

但如果id是String而不是String的列表,我应该使用什么DSL?

尝试阅读elastic4s文档和测试用例,但仍无法使其正常工作

1 个答案:

答案 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)
  }
}