Get distinct data

2014-09-02 Thread Alex T
Hi all!

I have problem with getting unique data from elasticsearch. I have the 
following documents:

[
{
 message: Message 1,
 author: {
  id: 4,
  name: Author Name
  },
  sourceId: 123456789,
  userId: 123456
},
{
 message: Message 1,
 author: {
  id: 4,
  name: Author Name
  },
  sourceId: 123456789,
  userId: 654321
}
]

Different between this documents in userId. When I send query by 
author.id, I get response with 2 documents.

Can I get distinct data by sourceId field?


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get distinct data

2014-09-02 Thread vineeth mohan
Hello Alex ,

Term aggregation is here to save your day -
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation

Thanks
  Vineeth


On Tue, Sep 2, 2014 at 12:07 PM, Alex T atri...@gmail.com wrote:

 Hi all!

 I have problem with getting unique data from elasticsearch. I have the
 following documents:

 [
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 123456
 },
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 654321
 }
 ]

 Different between this documents in userId. When I send query by 
 author.id, I get response with 2 documents.

 Can I get distinct data by sourceId field?


  --
 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+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com
 https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com?utm_medium=emailutm_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAGdPd5n_qZicXZp--7jX5vaip%3DJdadCrPQU0wzKmCYL494xmmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get distinct data

2014-09-02 Thread Alex T
Hi Vineeth! Thanks for your answer.

I use term aggregation, but I get anyway response with 2 documents, 
response data for example:


{
  took:23,
  timed_out:false,
  _shards:{total:5,successful:5,failed:0},
  hits:{
  total:2,
  max_score:null,
  hits:[
  {
  _index:feeditem_local,\
  _type:FeedItem,
  _id:53dbe9cf1d7859e15f8b4599,
  _score:null,
  _source:{
  sourceId:123456789, 
  message:Message 1,
  author:{id:120816414},
  userId: 123456
  },
  sort:[1406921136000]
  },
  {
  _index:feeditem_local,\
  _type:FeedItem,
  _id:53dbe9cf1d7859e15f8b4599,
  _score:null,
  _source:{
  sourceId:123456789, 
  message:Message 1,
  author:{id:120816414},
  userId: 654321
  },
  sort:[1406921136000]
  }
  ]
},
aggregations:{
source:{
buckets:[
{key:123456789,doc_count:2}
]
}
}
}




вторник, 2 сентября 2014 г., 9:45:41 UTC+3 пользователь vineeth mohan 
написал:

 Hello Alex , 

 Term aggregation is here to save your day - 
 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation

 Thanks
   Vineeth


 On Tue, Sep 2, 2014 at 12:07 PM, Alex T atr...@gmail.com javascript: 
 wrote:

 Hi all!

 I have problem with getting unique data from elasticsearch. I have the 
 following documents:

 [
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 123456
 },
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 654321
 }
 ]

 Different between this documents in userId. When I send query by 
 author.id, I get response with 2 documents.

 Can I get distinct data by sourceId field?


  -- 
 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 elasticsearc...@googlegroups.com javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com
  
 https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com?utm_medium=emailutm_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/8dccd0b8-972f-419c-bb94-3291d412844b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Get distinct data

2014-09-02 Thread vineeth mohan
Hello Alex ,

Aggregate based on sourceId field and you should get distinct sourceId
values.

Thanks
 Vineeth


On Tue, Sep 2, 2014 at 12:48 PM, Alex T atri...@gmail.com wrote:

 Hi Vineeth! Thanks for your answer.

 I use term aggregation, but I get anyway response with 2 documents,
 response data for example:


 {
   took:23,
   timed_out:false,
   _shards:{total:5,successful:5,failed:0},
   hits:{
   total:2,
   max_score:null,
   hits:[
   {
   _index:feeditem_local,\
   _type:FeedItem,
   _id:53dbe9cf1d7859e15f8b4599,
   _score:null,
   _source:{
   sourceId:123456789,
   message:Message 1,
   author:{id:120816414},
   userId: 123456
   },
   sort:[1406921136000]
   },
   {
   _index:feeditem_local,\
   _type:FeedItem,
   _id:53dbe9cf1d7859e15f8b4599,
   _score:null,
   _source:{
   sourceId:123456789,
   message:Message 1,
   author:{id:120816414},
   userId: 654321
   },
   sort:[1406921136000]
   }
   ]
 },
 aggregations:{
 source:{
 buckets:[
 {key:123456789,doc_count:2}
 ]
 }
 }
 }




 вторник, 2 сентября 2014 г., 9:45:41 UTC+3 пользователь vineeth mohan
 написал:

 Hello Alex ,

 Term aggregation is here to save your day - http://www.elasticsearch.
 org/guide/en/elasticsearch/reference/current/search-
 aggregations-bucket-terms-aggregation.html#search-
 aggregations-bucket-terms-aggregation

 Thanks
   Vineeth


 On Tue, Sep 2, 2014 at 12:07 PM, Alex T atr...@gmail.com wrote:

 Hi all!

 I have problem with getting unique data from elasticsearch. I have the
 following documents:

 [
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 123456
 },
 {
  message: Message 1,
  author: {
   id: 4,
   name: Author Name
   },
   sourceId: 123456789,
   userId: 654321
 }
 ]

 Different between this documents in userId. When I send query by 
 author.id, I get response with 2 documents.

 Can I get distinct data by sourceId field?


  --
 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 elasticsearc...@googlegroups.com.

 To view this discussion on the web visit https://groups.google.com/d/
 msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%
 40googlegroups.com
 https://groups.google.com/d/msgid/elasticsearch/1b59b2a2-484b-46cc-a95b-695e84e6d6eb%40googlegroups.com?utm_medium=emailutm_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+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/elasticsearch/8dccd0b8-972f-419c-bb94-3291d412844b%40googlegroups.com
 https://groups.google.com/d/msgid/elasticsearch/8dccd0b8-972f-419c-bb94-3291d412844b%40googlegroups.com?utm_medium=emailutm_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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAGdPd5kJ01uFysDPvYBh1ufdaER%3DniTO3hp26HRyS1kcFJU3%3Dg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.