Facet searching using Groovy DSL

I am trying to figure out the structure of a Groovy DSL for facet search.
My search should contain term facets and a range facet. I was able to
construct the search object using the facet builders:

    source.facet(new TermsFacetBuilder("type").field("types.type_id"))
    source.facet(new TermsFacetBuilder("state").field("state.state_id"))
    source.facet(new 

TermsFacetBuilder("category").field("categories.category_id"))
source.facet(new
RangeFacetBuilder("rating").field("avgRate").addRange(0.0,
1.0).addRange(1.0, 2.0).addRange(2.0, 3.0).addRange(3.0, 4.0).addRange(4.0,
5.0))

I also determined what the DSL looks like for the term facets:

    def facets = {
        type {
            terms (field : "types.type_id")
        }
        state {
            terms (field : "state.state_id")
        }
        category {
            terms (field : "categories.category_id")
        }
    }

Is there a regular way to construct the DSL for a range facet (other than
trial and error)? The DSL needs to specify that the facet is a range facet,
provide its name, set the field and add the ranges? Should the
RangeFacetBuilder API be the guide?

What should the Groovy DSL for a range facet look like?

Thank you,

Michael

The DSL should look similar to the json structure of the range facet, the
json builder from grails is used in elasticsearch.

On Tue, May 29, 2012 at 6:19 PM, Michael Smolyak <
msmolyak.nextcentury@gmail.com> wrote:

I am trying to figure out the structure of a Groovy DSL for facet search.
My search should contain term facets and a range facet. I was able to
construct the search object using the facet builders:

    source.facet(new TermsFacetBuilder("type").field("types.type_id"))
    source.facet(new

TermsFacetBuilder("state").field("state.state_id"))
source.facet(new
TermsFacetBuilder("category").field("categories.category_id"))
source.facet(new
RangeFacetBuilder("rating").field("avgRate").addRange(0.0,
1.0).addRange(1.0, 2.0).addRange(2.0, 3.0).addRange(3.0, 4.0).addRange(4.0,
5.0))

I also determined what the DSL looks like for the term facets:

    def facets = {
        type {
            terms (field : "types.type_id")
        }
        state {
            terms (field : "state.state_id")
        }
        category {
            terms (field : "categories.category_id")
        }
    }

Is there a regular way to construct the DSL for a range facet (other than
trial and error)? The DSL needs to specify that the facet is a range facet,
provide its name, set the field and add the ranges? Should the
RangeFacetBuilder API be the guide?

What should the Groovy DSL for a range facet look like?

Thank you,

Michael

Hi there did you manage to get anywhere with this? I've been trying to get
a facet range search working for a groovy/grails app, but not getting
anywhere... The DSL I have so far is

facets{
distance{
geo_distance{
"myfield"(lat:lat_long[0],lon:lat_long[1])
ranges([to:'5'],[from:"5",to:"10"])
}
}
}

but this the outputting....

facets={distance={geo_distance={myfield={lat=0.12, lon=-1.13},
ranges={to=5}}}}

On Tuesday, 29 May 2012 17:19:36 UTC+1, Michael Smolyak wrote:

I am trying to figure out the structure of a Groovy DSL for facet search.
My search should contain term facets and a range facet. I was able to
construct the search object using the facet builders:

    source.facet(new TermsFacetBuilder("type").field("types.type_id"))
    source.facet(new 

TermsFacetBuilder("state").field("state.state_id"))
source.facet(new
TermsFacetBuilder("category").field("categories.category_id"))
source.facet(new
RangeFacetBuilder("rating").field("avgRate").addRange(0.0,
1.0).addRange(1.0, 2.0).addRange(2.0, 3.0).addRange(3.0, 4.0).addRange(4.0,
5.0))

I also determined what the DSL looks like for the term facets:

    def facets = {
        type {
            terms (field : "types.type_id")
        }
        state {
            terms (field : "state.state_id")
        }
        category {
            terms (field : "categories.category_id")
        }
    }

Is there a regular way to construct the DSL for a range facet (other than
trial and error)? The DSL needs to specify that the facet is a range facet,
provide its name, set the field and add the ranges? Should the
RangeFacetBuilder API be the guide?

What should the Groovy DSL for a range facet look like?

Thank you,

Michael