Skip to content

Instantly share code, notes, and snippets.

@luizgpsantos
Created July 25, 2014 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luizgpsantos/b751724fc6267a9ae2d8 to your computer and use it in GitHub Desktop.
Save luizgpsantos/b751724fc6267a9ae2d8 to your computer and use it in GitHub Desktop.
Contador de palavras
PUT indice_teste
{
"settings": {
"analysis": {
"analyzer": {
"pt_analyzer": {
"type": "custom",
"filter": [
"stop_noise",
"lowercase"
],
"tokenizer": "standard"
}
},
"filter": {
"stop_noise": {
"type": "stop",
"stopwords": [
"na",
"no"
]
}
}
}
}
}
PUT /indice_teste/tipo_teste/_mapping
{
"tipo_teste": {
"properties": {
"frases": {
"type": "string",
"index": "analyzed",
"analyzer": "pt_analyzer"
}
}
}
}
POST indice_teste/tipo_teste/1
{
"frases": "na escola"
}
POST indice_teste/tipo_teste/2
{
"frases": "no escola parque"
}
POST indice_teste/tipo_teste/_search
{
"aggs" : {
"bla" : {
"terms":{
"field": "frases"
}
}
}, "size": 0
}
====================
Resultado:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0,
"hits": []
},
"aggregations": {
"bla": {
"buckets": [
{
"key": "escola",
"doc_count": 2
},
{
"key": "parque",
"doc_count": 1
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment