Hi everyone,
I'm new with ELK and developing social app.
I using ELK to query post and comment all of group social.
Desired result:
- If match text of post just show post.
- If match text of comment show that comment and post of it.
- If match text of both (comment, post) show 1 value of post with their comments.
field [relationshiptype] I was defined with type is [join] to create relationship between post and comment.
This is my index template:
{
"index_patterns": [
"<my-pattern>"
],
"template": {
"settings": {
"number_of_replicas": 2,
"max_ngram_diff": "20",
"analysis": {
"filter": {
"edgengram_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 15
}
},
"analyzer": {
"autocomplete": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding",
"edgengram_filter"
]
},
"folding": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding"
]
},
"htmlStripAnalyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding"
],
"char_filter": [
"my_custom_html_strip_char_filter"
]
}
},
"char_filter": {
"my_custom_html_strip_char_filter": {
"type": "html_strip",
"escaped_tags": [
"b"
]
}
}
}
},
"mappings": {
"properties": {
"id": {
"type": "keyword"
},
"relationshiptype": {
"type": "join",
"relations": {
"par": "chil"
}
},
"title": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "standard"
},
"shortdescription": {
"type": "text",
"analyzer": "htmlStripAnalyzer",
"search_analyzer": "folding"
},
"description": {
"type": "text",
"analyzer": "htmlStripAnalyzer",
"search_analyzer": "folding"
},
"image": {
"type": "text"
},
"type": {
"type": "keyword"
},
"tag": {
"type": "text",
"analyzer": "folding",
"search_analyzer": "folding"
},
"category": {
"type": "keyword"
},
"subcate": {
"type": "keyword"
},
"whitelist": {
"type": "keyword"
},
"source": {
"type": "keyword"
},
"rankingscore": {
"type": "integer"
},
"inapp": {
"type": "keyword"
},
"specialactive": {
"type": "text"
},
"isdelete": {
"type": "integer"
},
"datadetail": {
"dynamic": true,
"properties": {}
}
}
}
}
}
And I using this query:
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"has_child": {
"type": "chil",
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "discussion",
"fields": [
"description"
]
}
}
]
}
},
"inner_hits": {}
}
},
{
"multi_match": {
"query": "discussion",
"fields": [
"description"
]
}
}
]
}
}
}
},
"from": 0,
"size": "10",
"_source": [
"description",
"source"
]
}
Instead of just returning one parent and child result in inner_hits , here returns two duplicate results in inner_hit of result 1 and result 2 (field description)
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 2.871348,
"hits" : [
{
"_index" : "ep_portal",
"_type" : "_doc",
"_id" : "EPGROUP-EPGROUP-discussion-1256091458568192",
"_score" : 2.871348,
"_source" : {
"description" : "đây là discussion",
"source" : "EPGROUP"
},
"inner_hits" : {
"chil" : {
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 2.034186,
"hits" : [
{
"_index" : "ep_portal",
"_type" : "_doc",
"_id" : "EPGROUP-EPGROUP-comment-1256091912519680",
"_score" : 2.034186,
"_routing" : "EPGROUP-EPGROUP-discussion-1256091458568192",
"_source" : {
"isdelete" : 0,
"source" : "EPGROUP",
"type" : "comment",
"category" : "API Yammer Discussion",
"inapp" : "EPGROUP",
"datadetail" : {
"reactCustom" : null,
"message_type" : "update",
"body" : {
"rich" : "comment discussion",
"plain" : "comment discussion",
"parsed" : "comment discussion"
},
"isLike" : false,
"statusLike" : null,
"liked_by" : {
"names" : [ ],
"count" : 0
},
"thread_id" : 1256091458568192,
"isPublic" : 0,
"isStatus" : 1,
"typeThread" : "comment",
"id" : 1256091912519680,
"replied_to_id" : 1256091458568192,
"notified_user_ids" : [ ],
"sender_type" : "user",
"group_id" : 62244913152,
"IDDB" : 13,
"group_name" : "API Yammer Discussion",
"permission" : [ ],
"typePrivacy" : "public",
"isBestAnswer" : false,
"embed" : null,
"attachments" : [ ],
"sender_id" : 360023293952,
"infoUser" : {
"Fullname" : "Duy. Nguyễn Đức (8)",
"Department" : "Information Technology",
"Avatar" : "60c8828b83d41c9ax6594c5255ntC5OVE.jpgbreak60c8828b83d54c81c364hC55842bj4n12.jpg",
"Domain" : "duynd8",
"Title" : "Associate Software Engineer",
"UserID" : 360023293952
},
"lastTimeUpdate" : "2021-06-16 17:38:32",
"created_at" : "2021/06/16 10:38:32 +0000"
},
"rankingscore" : 0,
"update_at" : "2021-06-16T10:40:36.000Z",
"@timestamp" : "2021-06-16T10:40:39.758Z",
"relationshiptype" : {
"parent" : "EPGROUP-EPGROUP-discussion-1256091458568192",
"name" : "chil"
},
"tag" : [
"comment",
"comment discussion"
],
"shortdescription" : "",
"image" : "",
* "description" : "comment discussion",
"title" : "",
"specialactive" : [ ],
"create_at" : "2021-06-16T10:40:36.000Z",
"subcate" : "",
"whitelist" : [ ]
}
}
]
}
}
}
},
{
"_index" : "ep_portal",
"_type" : "_doc",
"_id" : "EPGROUP-EPGROUP-comment-1256091912519680",
"_score" : 2.034186,
"_routing" : "EPGROUP-EPGROUP-discussion-1256091458568192",
"_source" : {
* "description" : "comment discussion",
"source" : "EPGROUP"
},
"inner_hits" : {
"chil" : {
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
}
}
]
}
}
So is there any way to solve this problem of mine without using recursion in the backend?
I'm sorry , I'm not good at English.
Hope everyone understands, wish you all good health