Last active
February 4, 2020 14:01
-
-
Save gustavoapolinario/8843228a5ef69f6fd05700010d3941bb to your computer and use it in GitHub Desktop.
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
Rest Elasticsearch samples |
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 /_analyze?analyzer=standard&text=22+march+be+with+yoiu+(I+am+your+father) | |
GET /_analyze?analyzer=portuguese&text=Música |
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 /index/type/_bulk | |
{"create": {}} | |
{"field": "value", "field2": "value2"} | |
{"create": {}} | |
{"field": "value", "field2": "value2"} |
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
PUT /catalogo_v3 | |
{ | |
"settings": { | |
"index": { | |
"number_of_shards": 3, | |
"number_of_replicas": 0 | |
}, | |
"analysis": { | |
"filter": { | |
"portuguese_stop": { | |
"type": "stop", | |
"stopwords": "_portuguese_" | |
}, | |
"portuguese_stemmer": { | |
"type": "stemmer", | |
"language": "light_portuguese" | |
}, | |
"filtro_de_sinonimos": { | |
"type": "synonym", | |
"synonyms": [ | |
"futebol => futebol,society", | |
"society => society,futebol", | |
"volei,voleibol,volleyball", | |
"esport => esport,futebol,society,volei,basquet", | |
"exat => exat,matematic,fisic,computaca", | |
"arte => arte,pintur,teatr,music,cinem" | |
] | |
} | |
}, | |
"analyzer": { | |
"sinonimos": { | |
"tokenizer": "standard", | |
"filter": [ | |
"lowercase", | |
"portuguese_stop", | |
"portuguese_stemmer", | |
"filtro_de_sinonimos" | |
] | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"pessoas": { | |
"_all": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"properties": { | |
"cidade": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"estado": { | |
"type": "string" | |
}, | |
"formação": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"interesses": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese", | |
"search_analyzer": "sinonimos" | |
}, | |
"nome": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"país": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
} | |
} | |
} | |
} | |
} |
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
DELETE /index/type/id | |
DELETE /people/person/1 |
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 /<index>/<type>/_count | |
GET /people/person/_count | |
Response: | |
{ | |
"count": 1, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"failed": 0 | |
} | |
} |
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 /<index>/<type>/<id> | |
GET /people/person/1 | |
Response | |
{ | |
"_index": "people", | |
"_type": "person", | |
"_id": "1", | |
"_version": 1, | |
"found": true, | |
"_source": { | |
"name" : "Bruce wayne", | |
... | |
} | |
} |
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 /_cat/indices?v | |
GET /_cat/indices/twi*?v&s=index | |
Response | |
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size | |
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb | |
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b |
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 /index/_mapping | |
GET /people/_mapping |
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
Inside map, you can salve the original for search and a new modified by analyser | |
"name": { | |
"type": "string", | |
"fields": { | |
"original": { | |
"type": "string", | |
"index": "not_analyzed" | |
} | |
}, | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
} |
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 /people/person | |
POST /catalogo/pessoas/1 | |
Body | |
{ | |
"name" : "Bruce wayne", | |
"interests" : ["dark", "bat", "fight"], | |
"city" : "São Paulo", | |
"state" : "SP", | |
"country" : "Brasil" | |
} |
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
PUT /people/_settings | |
Body | |
{ | |
"index" : { | |
"number_of_replicas" : 0 | |
} | |
} |
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
PUT /catalogo_v2 | |
{ | |
"settings": { | |
"index": { | |
"number_of_shards": 3, | |
"number_of_replicas": 0 | |
} | |
}, | |
"mappings": { | |
"pessoas_v2": { | |
"_all": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"properties": { | |
"cidade": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"estado": { | |
"type": "string" | |
}, | |
"formação": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"interesses": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"nome": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
}, | |
"país": { | |
"type": "string", | |
"index": "analyzed", | |
"analyzer": "portuguese" | |
} | |
} | |
} | |
} | |
} |
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 /<index>/<type>/_search | |
GET /people/person/_search | |
GET /people/person/_search?q=bat | |
GET /people/person/_search?q=interests:bat | |
GET /people/person/_search?q=interests:bat&city:Paulo | |
GET /people/person/_search?q=bat&size=50&from=10 | |
GET /people/person/_search?q=_all:bat | |
/catalogo_v2/pessoas/_search?q=bat+AND+fight | |
Response | |
{ | |
"took": 11, | |
"timed_out": false, | |
"_shards": { | |
"total": 5, | |
"successful": 5, | |
"failed": 0 | |
}, | |
"hits": { | |
"total": 2, | |
"max_score": 1, | |
"hits": [ | |
{ | |
"_index": "people", | |
"_type": "person", | |
"_id": "E1Zp3AVK9Z-g4VXH09ly", | |
"_score": 1, | |
"_source": { | |
... | |
} | |
}, | |
... | |
] | |
} | |
} |
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 /index/_mapping/type | |
GET /people/_mapping/person | |
Response | |
{ | |
"people": { | |
"mappings": { | |
"person": { | |
"properties": { | |
"city": { | |
"type": "string" | |
}, | |
... | |
} | |
} | |
} | |
} | |
} |
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
HEAD /index/type/id | |
HEAD /people/person/1 |
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
PUT /index/_mapping/type | |
PUT /people/_mapping/person | |
{ | |
"properties": { | |
"number": { | |
"type": "integer" | |
} | |
} | |
} |
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 /people/person/1/_update | |
Body | |
{ | |
"doc": { | |
"name": "Clark Kent" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment