[ES 0.90.13] How to get the index name in a facet script?

Hi everybody,

I cannot figure out how to get the index name in a facet script with ES
0.90.13.
I tried the following syntax but neither of them didn't work:

with doc:

  • {*
  • "size": 0, *
  • "facets" : {*
  •  "indices" : { "terms" : {"script" : "doc['_index'].value"} }*
    
  • }*
  • }*

with _source:

  • {*
  • "size": 0, *
  • "facets" : {*
  •  "indices" : { "terms" : {"script" : "_source['_index']"} }*
    
  • }*
  • }*

Both of 2 syntax above return:
"facets": {
"indices": {
"_type": "terms",
"missing": 36289,
"total": 0,
"other": 0,
"terms": []
}
}

Should I use my own field instead of the built-in "_index" ?

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/32c05c7b-9e76-43e5-b0e3-05d663219cd7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I finally figured out that I forgot to enable the "_index" field in my
mapping as it's disabled by default:

"_index": {
"enabled": true
}

On Monday, 13 October 2014 11:34:12 UTC+2, Mehrez Marouani wrote:

Hi everybody,

I cannot figure out how to get the index name in a facet script with ES
0.90.13.
I tried the following syntax but neither of them didn't work:

with doc:

  • {*
  • "size": 0, *
  • "facets" : {*
  •  "indices" : { "terms" : {"script" : "doc['_index'].value"} }*
    
  • }*
  • }*

with _source:

  • {*
  • "size": 0, *
  • "facets" : {*
  •  "indices" : { "terms" : {"script" : "_source['_index']"} }*
    
  • }*
  • }*

Both of 2 syntax above return:
"facets": {
"indices": {
"_type": "terms",
"missing": 36289,
"total": 0,
"other": 0,
"terms":
}
}

Should I use my own field instead of the built-in "_index" ?

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/0560bfeb-1250-465d-ba87-57a351cab720%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.