Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
comp90024-demo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Houston Karnen
comp90024-demo
Commits
540be951
Commit
540be951
authored
1 year ago
by
Luca Morandini
Browse files
Options
Downloads
Patches
Plain Diff
- Used a different index to show the child-parent relationship for the sake of clarity
parent
1aa271c2
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
elastic/README.md
+10
-16
10 additions, 16 deletions
elastic/README.md
with
10 additions
and
16 deletions
elastic/README.md
+
10
−
16
View file @
540be951
...
...
@@ -107,7 +107,7 @@ curl -XGET -k "https://127.0.0.1:9200/students/_search"\
--data
'{
"query": {
"match": {
"course": "cloud
*
"
"course": "cloud"
}
}
}'
\
...
...
@@ -131,16 +131,9 @@ two documents should be returned (the expression language used in the Discover t
To avoid repeating data about the course, it is possible to create a parent-child relationship between the student and the course.
with some limitations.
Let's first delete the
`students`
index:
Create a
`coursesstudents`
database with a mapping that defines the parent-child relationship:
```
shell
curl
-XDELETE
-k
'https://127.0.0.1:9200/students'
--user
'elastic:elastic'
| jq
'.'
```
Then let's re-create the database with a mapping that defines the parent-child relationship:
```
shell
curl
-XPUT
-k
'https://127.0.0.1:9200/students'
\
curl
-XPUT
-k
'https://127.0.0.1:9200/coursesstudents'
\
--header
'Content-Type: application/json'
\
--data
'{
"settings": {
...
...
@@ -174,7 +167,7 @@ curl -XPUT -k 'https://127.0.0.1:9200/students' \
Let's insert some data about courses and students that use the parent-child relationship:
```
shell
curl
-XPUT
-k
"https://127.0.0.1:9200/students/_doc/comp90024?routing=comp"
\
curl
-XPUT
-k
"https://127.0.0.1:9200/
courses
students/_doc/comp90024?routing=comp"
\
--header
'Content-Type: application/json'
\
--data
'{
"name": "COMP90024",
...
...
@@ -185,7 +178,7 @@ curl -XPUT -k "https://127.0.0.1:9200/students/_doc/comp90024?routing=comp"\
}'
\
--user
'elastic:elastic'
| jq
'.'
curl
-XPUT
-k
"https://127.0.0.1:9200/students/_doc/1234567?routing=comp"
\
curl
-XPUT
-k
"https://127.0.0.1:9200/
courses
students/_doc/1234567?routing=comp"
\
--header
'Content-Type: application/json'
\
--data
'{
"name": "John Smith",
...
...
@@ -197,7 +190,7 @@ curl -XPUT -k "https://127.0.0.1:9200/students/_doc/1234567?routing=comp"\
}'
\
--user
'elastic:elastic'
| jq
'.'
curl
-XPUT
-k
"https://127.0.0.1:9200/students/_doc/0123456?routing=comp"
\
curl
-XPUT
-k
"https://127.0.0.1:9200/
courses
students/_doc/0123456?routing=comp"
\
--header
'Content-Type: application/json'
\
--data
'{
"name": "Jane Doe",
...
...
@@ -215,7 +208,7 @@ NOTE: the "routing" parameter has to be added so that all children are in the sa
Example of a query that returns all students of course whose description contains "computing" hat have a mark greater than 80:
```
shell
curl
-XGET
-k
"https://127.0.0.1:9200/students/_search"
\
curl
-XGET
-k
"https://127.0.0.1:9200/
courses
students/_search"
\
--header
'Content-Type: application/json'
\
--data
'{
"query": {
...
...
@@ -318,7 +311,7 @@ Match partial strings:
```
shell
POST /_sql?format
=
txt
{
"query"
:
"SELECT * FROM students WHERE MATCH(course
description
, 'computing')"
"query"
:
"SELECT * FROM students WHERE MATCH(course, 'computing')"
}
```
...
...
@@ -343,12 +336,13 @@ When there is a timestamp in your data, as it is the case for the `temperatures`
## Removal of indexes
To remove the data views in Kibana, go to "Management / Kibana / Data views" and delte the data views you want to remove.
To remove the data views in Kibana, go to "Management / Kibana / Data views" and del
e
te the data views you want to remove.
To remove the indexes created in this workshop, use the following commands:
```
shell
curl
-XDELETE
-k
'https://127.0.0.1:9200/students'
--user
'elastic:elastic'
| jq
'.'
curl
-XDELETE
-k
'https://127.0.0.1:9200/coursesstudents'
--user
'elastic:elastic'
| jq
'.'
curl
-XDELETE
-k
'https://127.0.0.1:9200/temperatures'
--user
'elastic:elastic'
| jq
'.'
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment