Presentor: Weiyuan Wu <youngw@sfu.ca>
Instructor: Jian Pei
SFU CMPT 456, Fall 2019
Users are forever searching...
...that makes search functionality one of the most important things
Lucene
Elasticsearch
Elasticsearch is distributed, open source search and analytics engine for all types of data.
Elasticsearch
Index: Wikipedia
Index: ....
Index: ....
Shard1
Shard2
Shard3
Documents
Lucene Index
Speak JSON
E.g.
Text: We have 107 students enrolled CMPT456 in Fall 2019
{
"class": "CMPT456",
"number of students": 107,
"year": "2019",
"semester": "Fall"
}
Structured:
{
"name":"Weiyuan",
"email": "youngw@sfu.ca",
"about": "TA for CMPT456",
"interests": ["sports","music"]
}
{
"title":"DeepDB: Learn from Data, not from Queries!",
"abstract": "The typical approach for learned DBMS...",
"body": "Motivation. Deep Neural Networks (DNNs)..."
}
d1 = {
"name":"Weiyuan",
"about": "TA for CMPT456",
"email": "youngw@sfu.ca",
"interests": ["sports","music"],
}
es.index(index="sfu", id=1, body=d1)
es.get(index="sfu", id=1)
-------------------------------------
{
'_index': 'sfu',
'_type': '_doc',
'_id': '1',
'_version': 1,
'_seq_no': 0,
'_primary_term': 1,
'found': True,
'_source': {
'name': 'Weiyuan',
'about': 'TA for CMPT456',
'email': 'youngw@sfu.ca',
'interests': ['sports', 'music']
}
}
docker run -it --rm -p9200:9200 -p9300:9300 wooya/cmpt456a4 standby
docker run -it --rm -v$PWD/src:/workdir/src wooya/cmpt456a4 demo.py
Port 9200
Port 9300
Normally, your program talk with Elasticsearch on port 9200 on you PC.
Port 9200
Port 9300
Communication failure
Port 9200
Port 9200
Port 9300
Port 9200
Port 9300
docker run -it --rm -p9200:9200 -p9300:9300 wooya/cmpt456a4 standby
Port 9200
Port 9300
Port 9200
Port 9300
docker run -it --rm -p9200:9200 -p9300:9300 wooya/cmpt456a4 standby
docker run -it --rm -v$PWD/src:/workdir/src wooya/cmpt456a4 demo.py
src/
|-- demo.py
|-- q1.py
|-- q2.py
|-- ...
+-- assignment4.py
/wordir/src
|-- demo.py
+-- ...
docker run -it --rm -v$PWD/src:/workdir/src wooya/cmpt456a4 demo.py
src/
|-- demo.py
|-- q1.py
|-- q2.py
|-- ...
+-- assignment4.py
/wordir/src
|-- demo.py
+-- ...