I'm new to the elastic search boards. As a long time Endeca user, I'm really enjoying working with ElasticSearch.
I would like to know if it is currently possible to generate a range facet against string data. Basically provide a range based on the String.compareTo function
I could obviously bake in the ranges at index time and do a simple term facet if I had to.
I was able to use a script (using js) to sort of achieve this goal - but I don't think I can get overlapping ranges like I can in the range facet, unless the script could return an array of term values - that would be cool
"facets" : {
"Title A-Z" : {
"terms" : {
"fields" : ["title.titleSort"],
"size" : 10,
"script" : "var x={"A":"A-E","B":"A-E","C":"A-E","D":"A-E","E":"A-E","F":"F-M"}; var y=x[term.substring(0,1).toUpperCase()]; y==null ? "Others" : y"
}
}
}
I'm super impressed how fast this runs on my laptop on a 35K record index. Awesome work!
Is there a convenient way to plug in additional Facet types?
There isn't a range facet support for string fields, can be added ... . One option is to use a set of filter facets (Elasticsearch Platform — Find real-time answers at scale | Elastic), each filter includes the relevant range using a range filter. It should be faster compared to what you are doing now (especially for subsequent executions).
On Tuesday, April 26, 2011 at 6:35 PM, joec wrote:
Hi all,
I'm new to the Elasticsearch boards. As a long time Endeca user, I'm really
enjoying working with Elasticsearch.
I would like to know if it is currently possible to generate a range facet
against string data. Basically provide a range based on the String.compareTo
function
I could obviously bake in the ranges at index time and do a simple term
facet if I had to.
I was able to use a script (using js) to sort of achieve this goal - but I
don't think I can get overlapping ranges like I can in the range facet,
unless the script could return an array of term values - that would be cool
"facets" : {
"Title A-Z" : {
"terms" : {
"fields" : ["title.titleSort"],
"size" : 10,
"script" : "var
x={"A":"A-E","B":"A-E","C":"A-E","D":"A-E","E":"A-E","F":"F-M"};
var y=x[term.substring(0,1).toUpperCase()]; y==null ? "Others" : y"
}
}
}
I'm super impressed how fast this runs on my laptop on a 35K record index.
Awesome work!
Is there a convenient way to plug in additional Facet types?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.