Created
July 25, 2014 02:17
-
-
Save luizgpsantos/b751724fc6267a9ae2d8 to your computer and use it in GitHub Desktop.
Contador de palavras
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 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