Can I use facet on script field?


(Olivier) #1

Hi,

Can I use facet on script field ?
For instance, I would like to dynamically extract some field with
regex and use it to specify field facet :
{
"query": {
"match_all": {}
},
"script_fields": {
"test1": {
"lang": "groovy",
"script": "(doc['some_field'].value =~ '([a-z]).*')[0][1]"
}
},
"facets": {
"tag": {
"terms": {
"field": "test1",
}
}
}
}


(Shay Banon) #2

Thats a script field which controls what will be returned from the actual search top N hits you ask for (the size). Each facet specifically has some support for scripting, terms as well.

On Monday, January 30, 2012 at 2:36 AM, Olivier wrote:

Hi,

Can I use facet on script field ?
For instance, I would like to dynamically extract some field with
regex and use it to specify field facet :
{
"query": {
"match_all": {}
},
"script_fields": {
"test1": {
"lang": "groovy",
"script": "(doc['some_field'].value =~ '([a-z]).*')[0][1]"
}
},
"facets": {
"tag": {
"terms": {
"field": "test1",
}
}
}
}


(Olivier) #3

Missed it.
Thanks Shay

On 1 fév, 10:01, Shay Banon kim...@gmail.com wrote:

Thats a script field which controls what will be returned from the actual search top N hits you ask for (the size). Each facet specifically has some support for scripting, terms as well.

On Monday, January 30, 2012 at 2:36 AM, Olivier wrote:

Hi,

Can I use facet on script field ?
For instance, I would like to dynamically extract some field with
regex and use it to specify field facet :
{
"query": {
"match_all": {}
},
"script_fields": {
"test1": {
"lang": "groovy",
"script": "(doc['some_field'].value =~ '([a-z]).*')[0][1]"
}
},
"facets": {
"tag": {
"terms": {
"field": "test1",
}
}
}
}


(system) #4