Master Cassandra distributed systems, Elasticsearch full-text search, and Neo4j graph databases. Work with cutting-edge NoSQL technologies used in production environments.
Distributed & Graph Databases - Module 9
Advanced NoSQL systems requiring hands-on CQL, REST API, and Cypher query skills!
Lab 25: Cassandra Distributed Database
NoSQL / Expert
Scenario: IoT Sensor Data Platform
TechSensors needs a highly available, distributed database for billions of IoT sensor readings. You must write CQL commands to create keyspaces, design wide-row tables with proper partitioning, and configure replication strategies. Each command is validated for correct syntax.
Learning Objectives:
Keyspace Creation: Define replication strategy and consistency levels
Table Design: Create wide-row tables with partition and clustering keys
Data Modeling: Write time-series data models with TTL
Queries: Use WHERE clauses with partition keys properly
π Step-by-Step Instructions
Step 1: Create Keyspace with Replication
Create a keyspace with NetworkTopologyStrategy and RF=3.
β’ CREATE KEYSPACE name WITH replication = {...};
β’ USE keyspace_name;
β’ CREATE TABLE name (col type, PRIMARY KEY ((partition), clustering));
β’ INSERT INTO table (cols) VALUES (vals);
β’ SELECT * FROM table WHERE partition_key = value;
Complete all 6 steps to see cluster data
Progress:0/6 tasks completed
Score: 0/100
0%
Lab Completed!
Excellent Cassandra mastery!
Lab 26: Elasticsearch Full-Text Search
Search / Expert
Scenario: News Article Search Engine
MediaCorp needs a powerful search engine for millions of news articles. You must write Elasticsearch REST API commands to create indices with mappings, configure analyzers for full-text search, and write complex queries with aggregations.
Learning Objectives:
Index Creation: Create indices with custom mappings and analyzers
Document Indexing: Index documents with proper field types
Full-Text Search: Write match, bool, and multi_match queries
Aggregations: Create bucket and metric aggregations
π Step-by-Step Instructions
Step 1: Create Index with Mappings
Create an index with explicit field mappings and analyzers.
Required API Call: PUT /news_articles
β’ Index name: news_articles
β’ Must define: mappings with properties
β’ Fields: title (text), content (text), author (keyword), published_date (date)
π‘ Tip: Use 'text' for full-text search, 'keyword' for exact match.
Step 2: Index a Document
Add a news article document to the index.
Required API Call: POST /news_articles/_doc
β’ Must include: title, content, author, published_date
π‘ Tip: POST auto-generates ID, PUT with /_doc/id for specific ID.
Step 3: Full-Text Match Query
Search articles using full-text match query.
Required Query: GET /news_articles/_search
β’ Must use: match query
β’ Search in: title or content field
π‘ Tip: match query analyzes search terms and finds relevant documents.
Step 4: Bool Query with Filters
Write a compound query with must, should, filter clauses.
Required Elements:
β’ Must use: bool query
β’ Include: must or should clause
β’ Include: filter for date range
π‘ Tip: filter doesn't affect scoring - use for date ranges, exact matches.
Step 5: Multi-Match Query
Search across multiple fields at once.
Required Query:
β’ Must use: multi_match query
β’ Search fields: ["title", "content"]
β’ Include: type parameter (best_fields or cross_fields)
π‘ Tip: best_fields returns docs matching best in any field.
Step 6: Aggregation Query
Create aggregations to analyze article data.
Required Elements:
β’ Must use: aggs or aggregations
β’ Include: terms aggregation on author
β’ Or: date_histogram on published_date
π‘ Tip: terms agg creates buckets by field value - great for faceted search!
Elasticsearch REST Console
elasticsearch:9200
Elasticsearch 8.11.0
Cluster: news-cluster (green)
Connected to localhost:9200
ES>Type REST commands (e.g., GET /_cluster/health)
ES>
Elasticsearch API Reference
β’ PUT /index_name - Create index
β’ POST /index/_doc - Index document
β’ GET /index/_search - Search documents
β’ GET /_cluster/health - Cluster status
Complete all 6 steps to see search index data
Progress:0/6 tasks completed
Score: 0/100
0%
Lab Completed!
Excellent Elasticsearch mastery!
Lab 27: Neo4j Graph Database
Graph / Expert
Scenario: Social Network Analysis
SocialNet needs a graph database to model user relationships, recommendations, and fraud detection. You must write Cypher queries to create nodes, relationships, and perform graph traversals and pattern matching.
Learning Objectives:
Node Creation: Create labeled nodes with properties
Relationships: Define typed relationships between nodes
Pattern Matching: Use MATCH to find graph patterns
Graph Algorithms: Find shortest paths and recommendations
π Step-by-Step Instructions
Step 1: Create User Nodes
Create user nodes with the Person label and properties.