mardi 19 août 2014

How do I create a Range Facet with QueryBuilder?


Vote count:

0




This may be a simple question, but I'm having trouble finding information on how to format my QueryBuilder call to add a range filter. I want my query to look like this:



{
"query" : {
"match_all" : {}
},
"facets" : {
"daterange" : {
"range" : {
"field" : "start_year",
"ranges" : [
{ "to" : 50 },
{ "from" : 20, "to" : 70 },
{ "from" : 70, "to" : 120 },
{ "from" : 150 }
]
}
}
}
}


Here is what I have so far:



var query = new QueryBuilder<ElasticCollection>()
.Query(q => q
.MatchAll()
)
.Facets(facets => facets
.Range(r => r.FacetName("DatabasesPerStartdate").Field("start_year").Ranges()


but I"m sort of stuck there. I can't figure out how to specify the ranges.


Also, this isn't as important, but is there a way to do multiple fields in my range facet so that it gets the count for items in "start_year" OR "end_year" ?



asked 24 secs ago







How do I create a Range Facet with QueryBuilder?

Aucun commentaire:

Enregistrer un commentaire