Re: Use facets to group documents by index and type

2014-04-24 Thread Radu Gheorghe
Great! You're welcome!


On Thu, Apr 24, 2014 at 3:26 PM, Sviatoslav Abakumov <
abakumov.sviatos...@progforce.com> wrote:

> Magnificent! That's what I like to see.
>
> Thank you so much!
>
>
> On Thu, Apr 24, 2014 at 4:23 PM, Radu Gheorghe  > wrote:
>
>> Ah, I see now. Sorry for misreading your initial post. You can do that
>> using scripts. This works for me:
>>
>> curl localhost:9200/_search?pretty -d '{
>> "facets": {
>>   "idxtype": {
>> "terms": {
>>   "script_field": "doc['"'_index'].value + '/' + doc['_type'"'].value"
>> }
>>   }
>> }}'
>>
>> Using doc['field_name'].value is usually preferred to _source or _fields
>> because with doc you're accessing values loaded in memory:
>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_document_fields
>>
>> Best regards,
>> Radu
>> --
>> Performance Monitoring * Log Analytics * Search Analytics
>> Solr & Elasticsearch Support * http://sematext.com/
>>
>> On Thu, Apr 24, 2014 at 2:54 PM, Sviatoslav Abakumov <
>> abakumov.sviatos...@progforce.com> wrote:
>>
>>> Oh, yes, I've enabled `_index` so I can do term facet requests like:
>>>
>>> {'field': '_index'}
>>> {'field': '_type'}
>>>
>>> And even:
>>>
>>> {'fields': ['_index', '_type']}
>>>
>>> There was a hope that this request does what I want, but it merely
>>> unites facets:
>>>
>>> {'_type': 'terms',
>>>  'missing': 0,
>>>  'other': 0,
>>>  'terms': [{'count': 198, 'term': 'comment'},
>>>{'count': 99, 'term': 'light_beer'},
>>>{'count': 99, 'term': 'dark_beer'}]}
>>>
>>> Well, I want to concatenate index and type names and pass it to ES
>>> facets. The only way I see is to use `script`, but I don't know how to
>>> access `_index` and `_type` from there.
>>>
>>> Thank you for understanding.
>>>
>>>
>>> On Thu, Apr 24, 2014 at 3:30 PM, Radu Gheorghe <
>>> radu.gheor...@sematext.com> wrote:
>>>
 Hello,

 I'm not sure if you're already aware of the predefined _index and _type
 fields:

 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-index-field.html

 http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-type-field.html

 You can enable them so you can search and retrieve values like you
 would with any other field.

 Best regards,
 Radu


  On Thu, Apr 24, 2014 at 11:28 AM, Sviatoslav Abakumov <
 abakumov.sviatos...@progforce.com> wrote:

>  Hello,
>
> I'd like to get how much documents of particular index AND type, like
> this:
>
> {'f4': {'_type': 'terms',
> 'missing': 0,
> 'other': 0,
> 'terms': [{'count': 99, 'term': 'light_beer/comment'},
>   {'count': 99, 'term': 'dark_beer/comment'}],
> 'total': 198}}
>
> To do this I added fields `__index` and `__type` and filled them when
> I was indexing documents.
> I use term facet with `"script": "_source.__index + '/' +
> _source.__type"`
>
> Is there a way to get index and type names from `_index` (IndexLookup)or 
> `_source` (SourceLookup)?
>
> Thank you.
>
> --
> 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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



 --
 Performance Monitoring * Log Analytics * Search Analytics
 Solr & Elasticsearch Support * http://sematext.com/

 --
 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/uSUHj5LcGdw/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 elasticsearch+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/elasticsearch/CAHXA0_0z5jD8cZfkca8FNOmcg7FnEeXL_S%3DZmJVcDm7PArixLQ%40mail.gmail.com
 .

 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, sen

Re: Use facets to group documents by index and type

2014-04-24 Thread Sviatoslav Abakumov
Magnificent! That's what I like to see.

Thank you so much!


On Thu, Apr 24, 2014 at 4:23 PM, Radu Gheorghe
wrote:

> Ah, I see now. Sorry for misreading your initial post. You can do that
> using scripts. This works for me:
>
> curl localhost:9200/_search?pretty -d '{
> "facets": {
>   "idxtype": {
> "terms": {
>   "script_field": "doc['"'_index'].value + '/' + doc['_type'"'].value"
> }
>   }
> }}'
>
> Using doc['field_name'].value is usually preferred to _source or _fields
> because with doc you're accessing values loaded in memory:
> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_document_fields
>
> Best regards,
> Radu
> --
> Performance Monitoring * Log Analytics * Search Analytics
> Solr & Elasticsearch Support * http://sematext.com/
>
> On Thu, Apr 24, 2014 at 2:54 PM, Sviatoslav Abakumov <
> abakumov.sviatos...@progforce.com> wrote:
>
>> Oh, yes, I've enabled `_index` so I can do term facet requests like:
>>
>> {'field': '_index'}
>> {'field': '_type'}
>>
>> And even:
>>
>> {'fields': ['_index', '_type']}
>>
>> There was a hope that this request does what I want, but it merely unites
>> facets:
>>
>> {'_type': 'terms',
>>  'missing': 0,
>>  'other': 0,
>>  'terms': [{'count': 198, 'term': 'comment'},
>>{'count': 99, 'term': 'light_beer'},
>>{'count': 99, 'term': 'dark_beer'}]}
>>
>> Well, I want to concatenate index and type names and pass it to ES
>> facets. The only way I see is to use `script`, but I don't know how to
>> access `_index` and `_type` from there.
>>
>> Thank you for understanding.
>>
>>
>> On Thu, Apr 24, 2014 at 3:30 PM, Radu Gheorghe <
>> radu.gheor...@sematext.com> wrote:
>>
>>> Hello,
>>>
>>> I'm not sure if you're already aware of the predefined _index and _type
>>> fields:
>>>
>>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-index-field.html
>>>
>>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-type-field.html
>>>
>>> You can enable them so you can search and retrieve values like you would
>>> with any other field.
>>>
>>> Best regards,
>>> Radu
>>>
>>>
>>>  On Thu, Apr 24, 2014 at 11:28 AM, Sviatoslav Abakumov <
>>> abakumov.sviatos...@progforce.com> wrote:
>>>
  Hello,

 I'd like to get how much documents of particular index AND type, like
 this:

 {'f4': {'_type': 'terms',
 'missing': 0,
 'other': 0,
 'terms': [{'count': 99, 'term': 'light_beer/comment'},
   {'count': 99, 'term': 'dark_beer/comment'}],
 'total': 198}}

 To do this I added fields `__index` and `__type` and filled them when I
 was indexing documents.
 I use term facet with `"script": "_source.__index + '/' +
 _source.__type"`

 Is there a way to get index and type names from `_index` (IndexLookup)or 
 `_source` (SourceLookup)?

 Thank you.

 --
 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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>> --
>>> Performance Monitoring * Log Analytics * Search Analytics
>>> Solr & Elasticsearch Support * http://sematext.com/
>>>
>>> --
>>> 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/uSUHj5LcGdw/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> elasticsearch+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/elasticsearch/CAHXA0_0z5jD8cZfkca8FNOmcg7FnEeXL_S%3DZmJVcDm7PArixLQ%40mail.gmail.com
>>> .
>>>
>>> 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/CAKmtHP-VZJ_gUG1Z7yESL6yihQCn8zZJ4kyZm%2B6FeAFJsvnMqA%40mail.gmail.com

Re: Use facets to group documents by index and type

2014-04-24 Thread Radu Gheorghe
Ah, I see now. Sorry for misreading your initial post. You can do that
using scripts. This works for me:

curl localhost:9200/_search?pretty -d '{
"facets": {
  "idxtype": {
"terms": {
  "script_field": "doc['"'_index'].value + '/' + doc['_type'"'].value"
}
  }
}}'

Using doc['field_name'].value is usually preferred to _source or _fields
because with doc you're accessing values loaded in memory:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html#_document_fields

Best regards,
Radu
-- 
Performance Monitoring * Log Analytics * Search Analytics
Solr & Elasticsearch Support * http://sematext.com/

On Thu, Apr 24, 2014 at 2:54 PM, Sviatoslav Abakumov <
abakumov.sviatos...@progforce.com> wrote:

> Oh, yes, I've enabled `_index` so I can do term facet requests like:
>
> {'field': '_index'}
> {'field': '_type'}
>
> And even:
>
> {'fields': ['_index', '_type']}
>
> There was a hope that this request does what I want, but it merely unites
> facets:
>
> {'_type': 'terms',
>  'missing': 0,
>  'other': 0,
>  'terms': [{'count': 198, 'term': 'comment'},
>{'count': 99, 'term': 'light_beer'},
>{'count': 99, 'term': 'dark_beer'}]}
>
> Well, I want to concatenate index and type names and pass it to ES facets.
> The only way I see is to use `script`, but I don't know how to access
> `_index` and `_type` from there.
>
> Thank you for understanding.
>
>
> On Thu, Apr 24, 2014 at 3:30 PM, Radu Gheorghe  > wrote:
>
>> Hello,
>>
>> I'm not sure if you're already aware of the predefined _index and _type
>> fields:
>>
>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-index-field.html
>>
>> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-type-field.html
>>
>> You can enable them so you can search and retrieve values like you would
>> with any other field.
>>
>> Best regards,
>> Radu
>>
>>
>>  On Thu, Apr 24, 2014 at 11:28 AM, Sviatoslav Abakumov <
>> abakumov.sviatos...@progforce.com> wrote:
>>
>>>  Hello,
>>>
>>> I'd like to get how much documents of particular index AND type, like
>>> this:
>>>
>>> {'f4': {'_type': 'terms',
>>> 'missing': 0,
>>> 'other': 0,
>>> 'terms': [{'count': 99, 'term': 'light_beer/comment'},
>>>   {'count': 99, 'term': 'dark_beer/comment'}],
>>> 'total': 198}}
>>>
>>> To do this I added fields `__index` and `__type` and filled them when I
>>> was indexing documents.
>>> I use term facet with `"script": "_source.__index + '/' +
>>> _source.__type"`
>>>
>>> Is there a way to get index and type names from `_index` (IndexLookup)or 
>>> `_source` (SourceLookup)?
>>>
>>> Thank you.
>>>
>>> --
>>> 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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Performance Monitoring * Log Analytics * Search Analytics
>> Solr & Elasticsearch Support * http://sematext.com/
>>
>> --
>> 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/uSUHj5LcGdw/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> elasticsearch+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/elasticsearch/CAHXA0_0z5jD8cZfkca8FNOmcg7FnEeXL_S%3DZmJVcDm7PArixLQ%40mail.gmail.com
>> .
>>
>> 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/CAKmtHP-VZJ_gUG1Z7yESL6yihQCn8zZJ4kyZm%2B6FeAFJsvnMqA%40mail.gmail.com
> .
>
> 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 fr

Re: Use facets to group documents by index and type

2014-04-24 Thread Sviatoslav Abakumov
Oh, yes, I've enabled `_index` so I can do term facet requests like:

{'field': '_index'}
{'field': '_type'}

And even:

{'fields': ['_index', '_type']}

There was a hope that this request does what I want, but it merely unites
facets:

{'_type': 'terms',
 'missing': 0,
 'other': 0,
 'terms': [{'count': 198, 'term': 'comment'},
   {'count': 99, 'term': 'light_beer'},
   {'count': 99, 'term': 'dark_beer'}]}

Well, I want to concatenate index and type names and pass it to ES facets.
The only way I see is to use `script`, but I don't know how to access
`_index` and `_type` from there.

Thank you for understanding.


On Thu, Apr 24, 2014 at 3:30 PM, Radu Gheorghe
wrote:

> Hello,
>
> I'm not sure if you're already aware of the predefined _index and _type
> fields:
>
> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-index-field.html
>
> http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-type-field.html
>
> You can enable them so you can search and retrieve values like you would
> with any other field.
>
> Best regards,
> Radu
>
>
> On Thu, Apr 24, 2014 at 11:28 AM, Sviatoslav Abakumov <
> abakumov.sviatos...@progforce.com> wrote:
>
>> Hello,
>>
>> I'd like to get how much documents of particular index AND type, like
>> this:
>>
>> {'f4': {'_type': 'terms',
>> 'missing': 0,
>> 'other': 0,
>> 'terms': [{'count': 99, 'term': 'light_beer/comment'},
>>   {'count': 99, 'term': 'dark_beer/comment'}],
>> 'total': 198}}
>>
>> To do this I added fields `__index` and `__type` and filled them when I
>> was indexing documents.
>> I use term facet with `"script": "_source.__index + '/' + _source.__type"`
>>
>> Is there a way to get index and type names from `_index` (IndexLookup)or 
>> `_source` (SourceLookup)?
>>
>> Thank you.
>>
>> --
>> 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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Performance Monitoring * Log Analytics * Search Analytics
> Solr & Elasticsearch Support * http://sematext.com/
>
> --
> 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/uSUHj5LcGdw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/CAHXA0_0z5jD8cZfkca8FNOmcg7FnEeXL_S%3DZmJVcDm7PArixLQ%40mail.gmail.com
> .
>
> 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/CAKmtHP-VZJ_gUG1Z7yESL6yihQCn8zZJ4kyZm%2B6FeAFJsvnMqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Use facets to group documents by index and type

2014-04-24 Thread Radu Gheorghe
Hello,

I'm not sure if you're already aware of the predefined _index and _type
fields:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-index-field.html
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-type-field.html

You can enable them so you can search and retrieve values like you would
with any other field.

Best regards,
Radu


On Thu, Apr 24, 2014 at 11:28 AM, Sviatoslav Abakumov <
abakumov.sviatos...@progforce.com> wrote:

> Hello,
>
> I'd like to get how much documents of particular index AND type, like this:
>
> {'f4': {'_type': 'terms',
> 'missing': 0,
> 'other': 0,
> 'terms': [{'count': 99, 'term': 'light_beer/comment'},
>   {'count': 99, 'term': 'dark_beer/comment'}],
> 'total': 198}}
>
> To do this I added fields `__index` and `__type` and filled them when I
> was indexing documents.
> I use term facet with `"script": "_source.__index + '/' + _source.__type"`
>
> Is there a way to get index and type names from `_index` (IndexLookup) or
> `_source` (SourceLookup)?
>
> Thank you.
>
> --
> 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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Performance Monitoring * Log Analytics * Search Analytics
Solr & Elasticsearch Support * http://sematext.com/

-- 
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/CAHXA0_0z5jD8cZfkca8FNOmcg7FnEeXL_S%3DZmJVcDm7PArixLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Use facets to group documents by index and type

2014-04-24 Thread Sviatoslav Abakumov
Hello,

I'd like to get how much documents of particular index AND type, like this:

{'f4': {'_type': 'terms',
'missing': 0,
'other': 0,
'terms': [{'count': 99, 'term': 'light_beer/comment'},
  {'count': 99, 'term': 'dark_beer/comment'}],
'total': 198}}

To do this I added fields `__index` and `__type` and filled them when I was 
indexing documents.
I use term facet with `"script": "_source.__index + '/' + _source.__type"`

Is there a way to get index and type names from `_index` (IndexLookup) or 
`_source` (SourceLookup)?

Thank you.

-- 
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/80604448-0bd5-499f-9c13-de096a732981%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.