-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
version: '2.2' | ||
services: | ||
es: | ||
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.0 | ||
container_name: es | ||
environment: | ||
- node.name=es | ||
- cluster.name=es-docker-cluster | ||
- discovery.seed_hosts=es | ||
- cluster.initial_master_nodes=es | ||
- bootstrap.memory_lock=true | ||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m" | ||
ulimits: | ||
memlock: | ||
soft: -1 | ||
hard: -1 | ||
volumes: | ||
- es_data:/usr/share/elasticsearch/data | ||
ports: | ||
- 9200:9200 | ||
networks: | ||
- elastic | ||
|
||
kibana: | ||
image: docker.elastic.co/kibana/kibana:7.9.0 | ||
container_name: kibana | ||
ports: | ||
- 5601:5601 | ||
environment: | ||
ELASTICSEARCH_URL: http://es:9200 | ||
ELASTICSEARCH_HOSTS: http://es:9200 | ||
networks: | ||
- elastic | ||
|
||
volumes: | ||
es_data: | ||
driver: local | ||
|
||
networks: | ||
elastic: | ||
driver: bridge |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# elasticsearch-sandbox kibana | ||
|
||
|
||
Vamos utilizar o kibana para rodar todos os comandos de criação de indices, para criar os documentos e buscar os mesmos. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# elasticsearch-sandbox kibana example 1 | ||
|
||
Vamos seguir os passos do artigo https://www.rtancman.com.br/information-retrieval/elasticsearch-como-ferramenta-de-busca.html#executando-comandos-do-elasticsearch |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# elasticsearch-sandbox kibana example 2 | ||
|
||
Vamos ver na prática como os analyzers e os tokenizers funcionam. | ||
|
||
``` | ||
PUT /example2 | ||
{ | ||
"settings": { | ||
"index": { | ||
"analysis": { | ||
"filter": { | ||
"synonym": { | ||
"type": "synonym", | ||
"lenient": true, | ||
"synonyms": [ | ||
"i-pod, i pod => ipod", | ||
"universe, cosmos" | ||
] | ||
} | ||
}, | ||
"analyzer": { | ||
"default": { | ||
"filter": [ | ||
"asciifolding", | ||
"lowercase", | ||
"stop", | ||
"synonym" | ||
], | ||
"tokenizer": "standard" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
GET /_analyze | ||
{ | ||
"tokenizer": "standard", | ||
"filter": [ "stop" ], | ||
"text": "a quick fox jumps over the lazy dog" | ||
} | ||
POST /example2/_analyze | ||
{ | ||
"analyzer": "default", | ||
"text": "Este é um exemplo de texto que eu gostaria de indexar." | ||
} | ||
POST /example2/_analyze | ||
{ | ||
"analyzer": "default", | ||
"text": "i pod e cosmos são coisas bem loucas!" | ||
} | ||
POST /example2/_doc | ||
{ | ||
"title":"Este é um exemplo de texto que eu gostaria de indexar." | ||
} | ||
POST /example2/_doc | ||
{ | ||
"title":"exemplo para comprar um i pod." | ||
} | ||
GET /example2/_search | ||
{ | ||
"query": { | ||
"query_string": { | ||
"query":"exemplo de texto", | ||
"analyzer": "default" | ||
} | ||
} | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# elasticsearch-sandbox python | ||
|
||
|
||
Vamos utilizar o cliente python oficial do elasticsearch que é o [elastic/elasticsearch-py](https://github.com/elastic/elasticsearch-py). | ||
|
||
O link da documentação é o [https://elasticsearch-py.readthedocs.io/en/master/index.html](https://elasticsearch-py.readthedocs.io/en/master/index.html). | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import datetime | ||
from elasticsearch import Elasticsearch | ||
es = Elasticsearch() | ||
|
||
doc = { | ||
'author': 'kimchy', | ||
'text': 'Elasticsearch: cool. bonsai cool.', | ||
'timestamp': datetime.now(), | ||
} | ||
res = es.index(index="test-index", id=1, body=doc) | ||
print(res['result']) | ||
|
||
res = es.get(index="test-index", id=1) | ||
print(res['_source']) | ||
|
||
es.indices.refresh(index="test-index") | ||
|
||
res = es.search(index="test-index", body={"query": {"match_all": {}}}) | ||
print("Got %d Hits:" % res['hits']['total']['value']) | ||
for hit in res['hits']['hits']: | ||
print("%(timestamp)s %(author)s: %(text)s" % hit["_source"]) |
Empty file.