# Terms facet mistake or CKAN problem

**URL:** <https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753>\
**Category:** Elasticsearch\
**Created:** [May 17, 2012, 9:09pm UTC](https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753 "2012-05-17T21:09:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Gomes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre_gomes/32/2881_2.png) [@Alexandre\_Gomes](https://discuss.elastic.co/u/Alexandre_Gomes)\
**Post date:** [May 17, 2012, 9:09pm UTC](https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753/1 "2012-05-17T21:09:50Z")

</div>

What's wrong with this query?

{  
"query":{  
"match\_all":{}  
},  
"facets":{  
"temas":{  
"terms":{ "field":"Tema" }  
}  
}  
}

It's not working as expected.

The URL

[http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/\_search?pretty=true&source={"query":{"match\_all":{}](http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/_search?pretty=true&source=%7B%22query%22:%7B%22match_all%22:%7B%7D)},"facets":{"temas":{"terms":{"field":"Tema"}}}

returns:

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 308,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "[ckan-www.ckan.net](http://ckan-www.ckan.net)",  
"\_type" : "4e256209-7e2d-4481-9627-da73e191baf2",  
"\_id" : "4",  
"\_score" : 1.0, "\_source" : {"Identificador": "1- Matriz de Responsabilidade", "Referencia": "RN-A.03/03", "observacao-cronograma": "", "Etapa": "3. Obras", "Investimento-Previsto-para-a-Etapa": "12,10000000", "Investimento-Executado-para-a-Etapa": "0,00000000", "Cidade-Sede": "Natal RN", "Responsabilidade-pela-Execucao": "Governo Estadual", "Previsao-de-Conclusao": "Mar/14", "Inicio-Efetivo": "-", "observacao-investimento": "", "Caminho": "natal/mobilidade-urbana/acesso-novo-aeroporto/", "Investimento-Contratado-para-a-Etapa": "0,00000000", "Responsabilidade-pelos-Recursos": "Governo Federal (Financiamento CAIXA)", "Identificacao": "RN-A.03", "Tema": "Mobilidade Urbana", "origem-dos-dados": "Min. Esporte", "Empreendimento/Acao": "Acesso ao Novo Aeroporto de SGono do Amarante", "Previsao-de-Inicio": "Jun/12", "Atualizado-em": "17/04/12", "Conclusao-Efetiva": "-"}  
},

....

}

thanks

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 18, 2012, 6:44am UTC](https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753/2 "2012-05-18T06:44:27Z")

</div>

Where is the error in the output? Is the Tema field analyzed?

2012/5/17 Alexandre Gomes [alegomes@gmail.com](mailto:alegomes@gmail.com):

> What's wrong with this query?
> 
> {  
> "query":{  
> "match\_all":{}  
> },  
> "facets":{  
> "temas":{  
> "terms":{ "field":"Tema" }  
> }  
> }  
> }
> 
> It's not working as expected.
> 
> The URL
> 
> [http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/\_search?pretty=true&source={"query":{"match\_all":{}](http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/_search?pretty=true&source=%7B%22query%22:%7B%22match_all%22:%7B%7D)},"facets":{"temas":{"terms":{"field":"Tema"}}}
> 
> returns:
> 
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 308,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "[ckan-www.ckan.net](http://ckan-www.ckan.net)",  
> "\_type" : "4e256209-7e2d-4481-9627-da73e191baf2",  
> "\_id" : "4",  
> "\_score" : 1.0, "\_source" : {"Identificador": "1- Matriz de  
> Responsabilidade", "Referencia": "RN-A.03/03", "observacao-cronograma": "",  
> "Etapa": "3. Obras", "Investimento-Previsto-para-a-Etapa": "12,10000000",  
> "Investimento-Executado-para-a-Etapa": "0,00000000", "Cidade-Sede": "Natal  
> RN", "Responsabilidade-pela-Execucao": "Governo Estadual",  
> "Previsao-de-Conclusao": "Mar/14", "Inicio-Efetivo": "-",  
> "observacao-investimento": "", "Caminho":  
> "natal/mobilidade-urbana/acesso-novo-aeroporto/",  
> "Investimento-Contratado-para-a-Etapa": "0,00000000",  
> "Responsabilidade-pelos-Recursos": "Governo Federal (Financiamento CAIXA)",  
> "Identificacao": "RN-A.03", "Tema": "Mobilidade Urbana", "origem-dos-dados":  
> "Min. Esporte", "Empreendimento/Acao": "Acesso ao Novo Aeroporto de SGono do  
> Amarante", "Previsao-de-Inicio": "Jun/12", "Atualizado-em": "17/04/12",  
> "Conclusao-Efetiva": "-"}  
> },
> 
> ....
> 
> }
> 
> thanks

---

<div class="post-metadata">

**Author:** ![Alexandre\_Gomes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexandre_gomes/32/2881_2.png) [@Alexandre\_Gomes](https://discuss.elastic.co/u/Alexandre_Gomes)\
**Post date:** [May 18, 2012, 12:06pm UTC](https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753/3 "2012-05-18T12:06:57Z")

</div>

I thinks it's supposed to return "facets" instead of "terms", isn't it?

{  
"took" : 2,  
"hits" : {  
"total" : 4,  
...  
},  
"facets" : {  
"tags" : {  
"\_type" : "terms",  
"missing" : 1,  
"terms" : [  
...  
]  
}  
}  
}

s!

2012/5/18 Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com)

> Where is the error in the output? Is the Tema field analyzed?
> 
> 2012/5/17 Alexandre Gomes [alegomes@gmail.com](mailto:alegomes@gmail.com):
> 
> > What's wrong with this query?
> > 
> > {  
> > "query":{  
> > "match\_all":{}  
> > },  
> > "facets":{  
> > "temas":{  
> > "terms":{ "field":"Tema" }  
> > }  
> > }  
> > }
> > 
> > It's not working as expected.
> > 
> > The URL
> 
> [http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/\_search?pretty=true&source=](http://thedatahub.org/api/data/4e256209-7e2d-4481-9627-da73e191baf2/_search?pretty=true&source=){  
> "query":{"match\_all":{}},"facets":{"temas":{"terms":{"field":"Tema"}}}
> 
> > returns:
> > 
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 308,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "[ckan-www.ckan.net](http://ckan-www.ckan.net)",  
> > "\_type" : "4e256209-7e2d-4481-9627-da73e191baf2",  
> > "\_id" : "4",  
> > "\_score" : 1.0, "\_source" : {"Identificador": "1- Matriz de  
> > Responsabilidade", "Referencia": "RN-A.03/03", "observacao-cronograma":  
> > "",  
> > "Etapa": "3. Obras", "Investimento-Previsto-para-a-Etapa": "12,10000000",  
> > "Investimento-Executado-para-a-Etapa": "0,00000000", "Cidade-Sede":  
> > "Natal  
> > RN", "Responsabilidade-pela-Execucao": "Governo Estadual",  
> > "Previsao-de-Conclusao": "Mar/14", "Inicio-Efetivo": "-",  
> > "observacao-investimento": "", "Caminho":  
> > "natal/mobilidade-urbana/acesso-novo-aeroporto/",  
> > "Investimento-Contratado-para-a-Etapa": "0,00000000",  
> > "Responsabilidade-pelos-Recursos": "Governo Federal (Financiamento  
> > CAIXA)",  
> > "Identificacao": "RN-A.03", "Tema": "Mobilidade Urbana",  
> > "origem-dos-dados":  
> > "Min. Esporte", "Empreendimento/Acao": "Acesso ao Novo Aeroporto de  
> > SGono do  
> > Amarante", "Previsao-de-Inicio": "Jun/12", "Atualizado-em": "17/04/12",  
> > "Conclusao-Efetiva": "-"}  
> > },
> > 
> > ....
> > 
> > }
> > 
> > thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:28am UTC](https://discuss.elastic.co/t/terms-facet-mistake-or-ckan-problem/7753/4 "2017-07-06T03:28:13Z")

</div>

Closed on July 6, 2017, 3:28am UTC


