私のマッピングを動作していないネストされたオブジェクトのためのフィルタが存在するがある:Elasticsearch 2.4、
"properties": {
"user": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
},
"is_active": {
"type": "boolean",
"null_value": false
},
"username": {
"type": "string"
}
}
},
私はuser
フィールドを持っていないすべての文書を取得したいです。
私が試した:すべての文書を返します
GET /index/type/_search
{
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
を。 ElasticSearch 2.x exists filter for nested field doesn't workに基づいて、私も試してみました:
GET /index/type/_search
{
"query": {
"nested": {
"path": "user",
"query": {
"bool": {
"must_not": [
{
"exists": {
"field": "user"
}
}
]
}
}
}
}
}
0の文書を返します。
user
フィールドがないすべてのドキュメントを取得する正しいクエリは何ですか?
あなたは 'の存在をテストしようとすることができます代わりにuser.id'フィールド?親ドキュメントに 'user'フィールドがない場合、' user.id'フィールドもありません。 – Val
私は十分にうまくいくだろうと思うが、ユーザーが設定されているが空であるという最悪のケースは見逃してしまう。 – pmishev