Aggregations with filter

Hi All,

I am new to elastic search . I am trying below query in order to get
results based on some where condition with group by and avg.

Query always returns zero hits, docs. If i remove terms , it is giving
results.

This was working fine sometime back.After i deleted the index and created a
new one, it is not working. Any pointers would help.

If I use fields which are not string as filter terms, it gives me proper
results.

{
"aggs": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"COLA": "NA"
}
},
{
"term": {
"COLB": "CUSTOMER"
}
} ,
{
"range": {
"SCORE": {
"from": 0,
"to": 90
}
}
}
]
}
} ,
"aggs" : {
"cust" : {
"terms" : {
"field" : "COLC"
},
"aggs" : {
"avg_score" : { "avg" : { "field" : "SCORE" } }
}
}
}
}
}
}

Thanks.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7b1cb3b5-7276-4ed8-a668-3cc7c285fbf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

A very likely cause for this issue is that by deleting and recreating your
index, you lost your mappings. Quite likely, you want to set your COLA,
COLB and COLC fields index=not_analyzed:

On Tue, Jul 15, 2014 at 8:57 PM, esuser subacini@gmail.com wrote:

Hi All,

I am new to Elasticsearch . I am trying below query in order to get
results based on some where condition with group by and avg.

Query always returns zero hits, docs. If i remove terms , it is giving
results.

This was working fine sometime back.After i deleted the index and created
a new one, it is not working. Any pointers would help.

If I use fields which are not string as filter terms, it gives me proper
results.

{
"aggs": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"COLA": "NA"
}
},
{
"term": {
"COLB": "CUSTOMER"
}
} ,
{
"range": {
"SCORE": {
"from": 0,
"to": 90
}
}
}
]
}
} ,
"aggs" : {
"cust" : {
"terms" : {
"field" : "COLC"
},
"aggs" : {
"avg_score" : { "avg" : { "field" : "SCORE" } }
}
}
}
}
}
}

Thanks.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/7b1cb3b5-7276-4ed8-a668-3cc7c285fbf0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/7b1cb3b5-7276-4ed8-a668-3cc7c285fbf0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7%2BvsQR%3D--C5w1b1_qE9vKTESR_LxpHy4ZdsmUOyRJ-mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Thank you Adrien, you are right it was mapping issue. I set analyzer to
keyword and it started working fine as expected.

On Wed, Jul 16, 2014 at 1:44 AM, Adrien Grand <
adrien.grand@elasticsearch.com> wrote:

Hi,

A very likely cause for this issue is that by deleting and recreating your
index, you lost your mappings. Quite likely, you want to set your COLA,
COLB and COLC fields index=not_analyzed:
Elasticsearch Platform — Find real-time answers at scale | Elastic

On Tue, Jul 15, 2014 at 8:57 PM, esuser subacini@gmail.com wrote:

Hi All,

I am new to Elasticsearch . I am trying below query in order to get
results based on some where condition with group by and avg.

Query always returns zero hits, docs. If i remove terms , it is giving
results.

This was working fine sometime back.After i deleted the index and created
a new one, it is not working. Any pointers would help.

If I use fields which are not string as filter terms, it gives me proper
results.

{
"aggs": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"COLA": "NA"
}
},
{
"term": {
"COLB": "CUSTOMER"
}
} ,
{
"range": {
"SCORE": {
"from": 0,
"to": 90
}
}
}
]
}
} ,
"aggs" : {
"cust" : {
"terms" : {
"field" : "COLC"
},
"aggs" : {
"avg_score" : { "avg" : { "field" : "SCORE" } }
}
}
}
}
}
}

Thanks.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/7b1cb3b5-7276-4ed8-a668-3cc7c285fbf0%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/7b1cb3b5-7276-4ed8-a668-3cc7c285fbf0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/udEUL5bJAzo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7%2BvsQR%3D--C5w1b1_qE9vKTESR_LxpHy4ZdsmUOyRJ-mQ%40mail.gmail.com
https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7%2BvsQR%3D--C5w1b1_qE9vKTESR_LxpHy4ZdsmUOyRJ-mQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAJfX5E27gVAJ52kPniF0Ly12vvPFLSW1CS9UzyGFe1hKLtU3ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.