0
0
Elasticsearchquery~10 mins

Lens for drag-and-drop analysis in Elasticsearch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Lens visualization with drag-and-drop fields.

Elasticsearch
POST /_lens/visualize
{
  "title": "Sales by Category",
  "type": "[1]",
  "state": {
    "datasourceStates": {},
    "visualization": {}
  }
}
Drag options to blanks, or click blank then click option'
Abar
Bpie
Cline
Dtable
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'pie' when a bar chart is needed.
Using 'table' which is not a chart type in Lens.
2fill in blank
medium

Complete the code to specify the field to drag into the Lens visualization.

Elasticsearch
"state": {
  "datasourceStates": {
    "indexpattern": {
      "layers": {
        "layer1": {
          "columns": {
            "col1": {
              "operationType": "sum",
              "sourceField": "[1]"
            }
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atimestamp
Bcategory
Cprice
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting a text field like 'category' for a sum operation.
Using a date field like 'timestamp' for sum.
3fill in blank
hard

Fix the error in the Lens state by completing the missing field for bucket grouping.

Elasticsearch
"columns": {
  "col1": {
    "operationType": "terms",
    "sourceField": "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Aprice
Buser
Ctimestamp
Dcategory.keyword
Attempts:
3 left
💡 Hint
Common Mistakes
Using a numeric field like 'price' for terms aggregation.
Using a text field without '.keyword' suffix.
4fill in blank
hard

Fill both blanks to set the correct operation and field for a date histogram in Lens.

Elasticsearch
"columns": {
  "col1": {
    "operationType": "[1]",
    "sourceField": "[2]"
  }
}
Drag options to blanks, or click blank then click option'
Adate_histogram
Btimestamp
Cterms
Dcategory.keyword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'terms' operation for date fields.
Using a non-date field for date histogram.
5fill in blank
hard

Fill all three blanks to create a Lens visualization with a sum metric and bucket by category.

Elasticsearch
{
  "title": "Sales by Category",
  "type": "bar",
  "state": {
    "datasourceStates": {
      "indexpattern": {
        "layers": {
          "layer1": {
            "columns": {
              "col1": {
                "operationType": "[1]",
                "sourceField": "[2]"
              },
              "col2": {
                "operationType": "[3]",
                "sourceField": "category.keyword"
              }
            }
          }
        }
      }
    },
    "visualization": {}
  }
}
Drag options to blanks, or click blank then click option'
Asum
Bprice
Cterms
Ddate_histogram
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'date_histogram' for the bucket by category column.
Using a text field for sum operation.