코멘트 용 중첩 필드가 포함 된 블로그 객체에 대한 ElasticSearch 매핑이 있습니다. 이것은 사용자가 위에 표시된 블로그 콘텐츠에 댓글을 추가 할 수 있도록하기위한 것입니다. 주석 필드에는 주석을 다른 사용자가 볼 수 있는지 또는 주 사용자 만 볼 수 있는지 여부를 결정하는 게시 된 플래그가 있습니다.ElasticSearch - "부모"객체에 영향을주지 않고 중첩 객체를 필터링합니다.
"blogs" :[
{
"id":1,
"content":"This is my super cool blog post",
"createTime":"2017-05-31",
"comments" : [
{"published":false, "comment":"You can see this!!","time":"2017-07-11"}
]
},
{
"id":2,
"content":"Hey Guys!",
"createTime":"2013-05-30",
"comments" : [
{"published":true, "comment":"I like this post!","time":"2016-07-01"},
{"published":false, "comment":"You should not be able to see this","time":"2017-10-31"}
]
},
{
"id":3,
"content":"This is a blog without any comments! You can still see me.",
"createTime":"2017-12-21",
"comments" : None
},
]
각 블로그 개체에 대해 참 댓글 만 표시되도록 댓글을 필터링하고 싶습니다. 진정한 의견을 가진 사람들뿐만 아니라 모든 블로그를 보여주고 싶습니다. 온라인에서 찾은 다른 모든 솔루션은 내 블로그 개체에 영향을 미치는 것 같습니다. 모든 블로그의 질의에 영향을 미치지 않고 코멘트 객체를 필터링하는 방법이 있습니까?
따라서 위의 예는 다음과 같은 쿼리 후 반환되는 :
"blogs" :[
{
"id":1,
"content":"This is my super cool blog post",
"createTime":"2017-05-31",
"comments" : None # OR EMPTY LIST
},
{
"id":2,
"content":"Hey Guys!",
"createTime":"2013-05-30",
"comments" : [
{"published":true, "comment":"I like this post!","time":"2016-07-01"}
]
},
{
"id":3,
"content":"This is a blog without any comments! You can still see me.",
"createTime":"2017-12-21",
"comments" : None
},
]
예는 여전히 의견이나 거짓 의견이없는 블로그를 보여줍니다.
이것이 가능합니까?
나는이 예에서 중첩 된 쿼리를 사용하고 있습니다 : ElasticSearch - Get only matching nested objects with All Top level fields in search response
을하지만이 예는 자체 블로그에 영향을 미치는 만 잘못된 의견이나 댓글 없음이 블로그를 반환하지 않습니다.
제발 도와주세요 :) 감사합니다!