Hi

I have this scenario of discussion board where people create discussion 
thread called post. Other can comment on it called comment. Now comment i 
same as post except it as parentId stored in it. In other words, my 
database schema for post table is 

Post


PostId, PostSubjectId, PostTitle, PostData, PostKind, PostDate


*PostSubjectId *is *PostId *of some post which is parent to the post and is 
null for parent post.

*Postkind *is a enum value which says *Post *for parent post and *Comment *for 
child posts.

Now, I have stored this document in elasticsearch with help of _id, 
_routing and _parent mapping I have mapped ids and parent ids 
appropriately. My mapping looks like:


PUT search 
{
    "mappings": {
        "post":{
            "_id": {
                "path": "postid"
            },
            "_routing": {
                "path": "postsubjectid",
                "required":false
            },
            "_parent" : {
                "type" : "post"
            },
             "properties": {
                 "postid": {
                    "type": "long"
                 },
                 "postsubjectid": {
                    "type": "long"                    
                 },
                 "posttitle":{
                     "type": "string",
                     "index": "analyzed"
                 },
                 "postdata":{
                     "type": "string",
                     "index": "analyzed"
                 },
                 "postdate":{
                     "type": "date",
                     "format": "date_hour_minute_second_millis"
                 },
                 "postkind": {
                    "type": "string",
                    "index": "not_analyzed",                    
                    "omit_norms": true,
                    "index_options": "docs"
                 }         
             }
        }
    }
}


Every parent post can have multiple comments/child posts. Parent Posts 
along with comments ordered by PostDate is called a discussion and shown as 
discussion on user interface. We need to implement search on discussions. 

I want to write a query which search across discussions not posts and 
return me parent posts when either parent post or child post has a search 
hit. I can think of has_child clause but am confused while creating this 
query as it includes both searching in parent as well as child together.




-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/52d12891-5c14-4b06-81ce-295931b98e12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to