Elasticsearch 1.7 と Elastic4s DSL を使用しています。私の問題は、ネストされたドキュメントを追加および & またはフィルター処理できないことです。たとえば、ケース クラス Candidate のインスタンスの JSON 表現は次のとおりです。
{
"name": "Samy"
"interviews": [
{
"clientId": 0,
"stateId": "CANCELED",
},
{
"clientId": 1,
"stateId": "APPROVED"
}
]
これが私のフィルターです:
def filtering(interviewAndCandidates: IntCand)(implicit user: PublicUser): Seq[FilterDefinition] = {
nestedFilter("interviews").filter(termFilter("clientId", user.id)) ::
List(or(interviewAndCandidates.interviews.map(state ⇒ nestedFilter("interviews").filter(termFilter("stateId", state)))))
}
次に、クエリを作成します。
var request: SearchDefinition = search in "myIndex" -> "candidate" query {
filteredQuery query {
matchAllQuery
} filter {
and(filters)
}
}
と:
case class IntCand(interviews: List[String])
case class Candidate(name: String, interviews: List[Interview])
case class Interview(clientId: Long, stateId: String)
問題は、IntCand(List("CANCELED")) と clientId=1 でフィルタリングすると、応答に候補者が表示されることです (clientId とインタビューでフィルタリングしたい)