0

我用作 elastic4s 库与 ElasticSearch 进行通信。我想做一个相当于“SELECT * FROM WHERE MY_INDEX MY_FIELD IN (VALUE_1, VALUE_2, ....)”

我产生了那个查询

val req = search in indexName -> {query indexType
   {bool
     must (
       termsQuery ("myField" transformed (myListOfValues))
     )
   }
}

方法 termsQuery 在 elastis4s 中定义如下

def termsQuery (field: String, capital gains: AnyRef *): TermsQueryDefinition

如何将 myListOfValues 列表转换为 AnyRef *

谢谢您的帮助。

4

1 回答 1

0

您没有说 ListOfValue 的类型是什么,但假设它是 Scala 集合类型,那么您可以执行 '_ : *' 例如

termsQuery ("myField", transformed (myListOfValues) : _*)
于 2015-07-01T12:58:32.277 回答