This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST movies/_doc/1 | |
{ | |
"title": "The Godfather", | |
"year": 1972, | |
"director": "Francis Ford Coppola", | |
"stars": [ | |
"Marlon Brando", | |
"Al Pacino", | |
"James Caan" | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST movies/_doc/2 | |
{ | |
"title": "The Dark Night", | |
"year": 2008, | |
"director": "Christopher Nolan", | |
"stars": [ | |
"Christian Bale", | |
"Heath Ledger", | |
"Aaron Eckhart" | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET movies/_search | |
{ | |
"query": { | |
"match": { | |
"director": "Nolan" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"took": 2, | |
"timed_out": false, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"skipped": 0, | |
"failed": 0 | |
}, | |
"hits": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET movies/_search | |
{ | |
"query": { | |
"match": { | |
"year": 2015 | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"took": 10, | |
"timed_out": false, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"skipped": 0, | |
"failed": 0 | |
}, | |
"hits": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nomes_list = ["Leonardo", "Jao", "Ana"] # Mais devagar, usando list | |
if "Pythonson" in nomes_list: | |
print("Pythonson ta na lista de nomes") | |
else: | |
print("Pythonson nao ta na lista de nomes") | |
nomes_set = {"Leonardo", "João", "Ana"} # Mais rápido, usando set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nomes = ["Leonardo", "Jao", "Ana"] | |
# Mais lento, não pythonico | |
nomes_com_o = [] | |
for nome in nomes: | |
if 'o' in nome: | |
nomes_com_o.append(nome) | |
nomes_com_o = [nome for nome in nomes if 'o' in nomes] # Mais rápido, legível e pythonico |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nomes = ["Leonardo", "Jao", "Ana"] | |
# Mais lento, usa mais memória pois cada vez que nomes_string | |
# recebe um valor um novo objeto em memória criado | |
nomes_string = "" | |
for nome in nomes: | |
nomes_string += nome | |
nomes_string = ''.join(nomes) # Mais rápido, pythonico e usa menos memória |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
python3 get-pip.py | |
sudo apt-get install -y python3-venv | |
python3 -m venv elasticsearch_loader | |
source elasticsearch_loader/bin/activate | |
pip3 install elasticsearch_loader |