अंतर्ज्ञान: एसक्यूएल भाषा में:
Select distinct full_name from authors;
बराबर है
Select full_name from authors group by full_name;
तो करने के लिए, हम अलग प्रविष्टियाँ खोजने के लिए ElasticSearch में समूहीकरण/कुल सिंटैक्स का उपयोग कर सकते हैं ।
मान लें निम्नलिखित संरचना लोचदार खोज में जमा हो जाती है:
[{
"author": "Brian Kernighan"
},
{
"author": "Charles Dickens"
}]
क्या काम नहीं किया: सादा एकत्रीकरण
{
"aggs": {
"full_name": {
"terms": {
"field": "author"
}
}
}
}
मैं निम्नलिखित त्रुटि मिली:
{
"error": {
"root_cause": [
{
"reason": "Fielddata is disabled on text fields by default...",
"type": "illegal_argument_exception"
}
]
}
}
क्या एक आकर्षण की तरह काम किया: क्षेत्र
{
"aggs": {
"full_name": {
"terms": {
"field": "author.keyword"
}
}
}
}
और नमूना उत्पादन के साथ जोड़ .keyword हो सकता है:
{
"aggregations": {
"full_name": {
"buckets": [
{
"doc_count": 372,
"key": "Charles Dickens"
},
{
"doc_count": 283,
"key": "Brian Kernighan"
}
],
"doc_count": 1000
}
}
}
बोनस टिप:
आइए हम क्यू में फ़ील्ड मान लें
[{
"authors": [{
"details": [{
"name": "Brian Kernighan"
}]
}]
},
{
"authors": [{
"details": [{
"name": "Charles Dickens"
}]
}]
}
]
अब सही क्वेरी हो जाता है::
{
"aggregations": {
"full_name": {
"aggregations": {
"author_details": {
"terms": {
"field": "authors.details.name"
}
}
},
"nested": {
"path": "authors.details"
}
}
},
"size": 0
}
FULL_NAME क्या मतलब है stion इस प्रकार नीडिंत है? – neustart47
@ neustart47 full_name सिर्फ समेकन का नाम है –