Skip to content

Instantly share code, notes, and snippets.

View luizgpsantos's full-sized avatar
😁

Luiz Guilherme Pais dos Santos luizgpsantos

😁
View GitHub Profile

Keybase proof

I hereby claim:

  • I am luizgpsantos on github.
  • I am luizgpsantos (https://keybase.io/luizgpsantos) on keybase.
  • I have a public key ASCJGrdw4Sbh_e26BeRBFybp61FJH-om-0Ppx98OfexaGAo

To claim this, I am signing this object:

@luizgpsantos
luizgpsantos / ElasticsearchExample.java
Last active December 8, 2017 13:54
Java Transport Client
package test;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
package test;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.entity.ContentType;
import org.apache.http.nio.entity.NStringEntity;
echo "Delete document"
curl -XDELETE 'http://localhost:8888/'
echo ""
echo "\nInitial search"
curl -XGET 'http://localhost:8888/'
echo ""
echo "\nCreate document"
curl -XPUT 'http://localhost:8888/'
curl -XPOST "http://localhost:9200/index_name" -d'
{
"mappings": {
"your_type": {
"properties": {
"colours": {
"type": "string",
"index": "not_analyzed"
}
}
@luizgpsantos
luizgpsantos / new relic logs
Created January 7, 2015 16:36
Elasticsearch nre relic plugin logs
[2015-01-07 14:34:46,411][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.filtercache.memorySizeInBytes: 0.0
[2015-01-07 14:34:46,412][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.filtercache.evictions: 0.0
[2015-01-07 14:34:46,412][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.idcache.memorySizeInBytes: 0.0
[2015-01-07 14:34:46,412][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.docs.count: 1.0
[2015-01-07 14:34:46,412][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.docs.deleted: 0.0
[2015-01-07 14:34:46,413][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.flush.total: 0.0
[2015-01-07 14:34:46,413][TRACE][org.elasticsearch.service.newrelic.NewRelicReporter] * elasticsearch.dev.node.flush.totalTimeInMillis: 0.0
[2015-01-07 14:34:46,413][TRACE][org.elasticsearch.service.newrelic
@luizgpsantos
luizgpsantos / context_suggester
Last active August 29, 2015 14:11
context suggester
# create an index called "services" with suggest_field mapped as "completion" with payloads
POST services
{
"mappings": {
"service": {
"properties": {
"name": {
"type": "string"
},
"suggest_field": {
@luizgpsantos
luizgpsantos / gist:125656e2132097184a72
Created September 15, 2014 13:04
listar indices java api
import java.io.IOException;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
public class Teste {
@luizgpsantos
luizgpsantos / gist:a1ca8b87b70ae4c2cf5c
Created September 12, 2014 13:53
Simulate timeout
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=[{"host": "localhost", "port": 9200}])
print es.search(body={
"query": {
"function_score": {
"query": {
"match_all": {}
},
@luizgpsantos
luizgpsantos / Exemplo completo
Last active November 25, 2022 23:27
Analyzer para plural e acentos no elasticsearch
// Ao [criar o índice][0], especifique um [analyzer customizado][1] responsável por tratar palavras
// com caracteres especiais e o plural da lingua Portuguesa. Algumas palavras precisarão de uma
// sintonia fina, o que pode ser feito através de [stemmer overrides][2]. Além disso, ao criar um
// campo atribua o analyzer a ele.
PUT produtos
{
"settings": {
"analysis": {
"analyzer": {