1

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

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

}

但是如果id是字符串列表而不是字符串,我应该使用什么 DSL?

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

4

1 回答 1

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)
  }
}
于 2015-06-03T11:27:09.457 回答