Hi,
Try using scripts. As following. They modify the field value before
applying faceting.
curl -XGET 'http://localhost:9200/try_test/data/_search?pretty=true' -d '{
"query": {
"match_all": {}
},
"facets": {
"my_facet": {
"terms": {
"script_field":
"(_source.value+"").toLowerCase().substring(0,9)",
"size": 10
}
}
}
}'
This is a copy from some stuff I was recently working with, so you need to
modify a bit to meet your details (fields and requirement).
Sujoy,
On Tuesday, July 24, 2012 9:17:34 PM UTC+5:30, Joe Wong wrote:
I have a field called createdDate of type string and it's not analyzed. A
sample entry for this field is "20120724120000"I like to run facets on this field after a certain query and do a facet
count. However I want the facet to count based on a certain portion of the
field. I am using the regex option to this.for example i have a few ES documents that contain:
20120724120000
20120724120001
20120724120002
20120725120021
20120726120034i like facets to count 20120724 =t 3, 20120725 = 1, 20120726 = 1 etc.
here is my facet query
curl -X POST "localhost:9200/stuff/_search?pretty=true" -d '{
"query": {
"text" : {
"message" : {
"query" : "test query",
"operator" : "and"
}
}
},
"facets" : { "createdDate" : { "terms" : {"field" : "createdDate", "size"
: 2000, "regex" : "[0-9]{8}"}}}}'The quantifier doesn't seem to be working for me, it returns 0 results.
Is it the correct syntax?
I'm using 0.19.6thanks