Me again;)

This looks like what I need but can't get it to work...

Here's the query:

GET /articles/_search
 {
      "aggs": {
        "group_by_id": {
          "terms": {
            "field": "id",
            "size":0
          },
          "aggs": {
            "sum_count": {
              "value_count": {
                "field": "tags"
              }
            }
          }
        }
      }
    }

Here's the data:

POST /articles/article
{"title" : "One",   "tags" : ["foo"]}
POST /articles/article
{"title" : "Two",   "tags" : ["foo", "bar"]}
POST /articles/article
{"title" : "Three", "tags" : ["foo", "bar", "baz"]}

And what I hope to achieve is 
id1, 1
id2, 2
id3,3

in other words the count of tags in the list.

Thanks.

On Tuesday, April 29, 2014 9:25:17 PM UTC+1, [email protected] wrote:
>
> Folks 
>
> Apologies about the multiple posts yesterday. A problem with the mobile 
> device I borrowed, (not android).
>
> Anyway what I was getting at is lets say you have rows in a database
>
> Then what I want to do is:
> select col1, count(col2) group by col1
>
> Is this an option in Elasticsearch ? 
>
> If I have to do something like: create index2 as select col1, count(col2) 
> group by col1 then okay I will do that in Elasticsearch.....
>
> How do I get these statistics on the data?
>
> Thanks.
>
> On Tuesday, April 29, 2014 12:11:58 AM UTC+1, [email protected] wrote:
>>
>> Yes you're right I thought of that. 
>>
>> But I just want to get some counts 
>>
>> Not a permanent count. Not a development change. I might want to get 
>> other counts another day. 
>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/0e6fd36f-5f01-4aa2-bff5-a4388a18c24b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to