lucene-ruby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: apply facet.query feature on Flare
Date Sun, 28 Oct 2007 14:44:13 GMT

Nice to see you here!   I have recently noticed your work with Flare  
and been very pleased to see someone give it a try besides myself :)

First a disclaimer: Flare is just a stupid simple hack at this  
point.  Using it for anything other than quick "wow" demos hasn't  
really been attempted that I'm aware of and it has a ways to go to be  
where I'd like to see it.

Now on to your question...

On Oct 28, 2007, at 12:51 AM, Koji Sekiguchi wrote:
> I'm starting to use Flare. I like the idea of @flare is a user  
> session.

I'd like to see this evolve into multiple flare contexts possible per  

> class Browse2Controller < ApplicationController
> flare
> def index
> @results_per_page = 10
> # name => {:queries => [], :filters => []}
> @flare.facet_queries = {
> '-49.99'=>{:queries=>['price:[0 TO 49.99]'],:filters=>[]},
> '50-99.99'=>{:queries=>['price:[50 TO 99.99]'],:filters=>[]},
> '100-99.99'=>{:queries=>['price:[100 TO 299.99]'],:filters=>[]},
> '300-'=>{:queries=>['price:[300 TO *]'],:filters=>[]}
> }
> if params[:page]
> = params[:page].to_i
> end
> @start = ( - 1) * @results_per_page
> @response =, @results_per_page)
> end
> end
> How can I use facet.query feature on Flare?

I just cobbled this example of an index method that sets the  

   def index
     @flare.facet_queries = {"foo"=>{:filters=>[], :queries=> 
     @response =, @results_per_page)

Notice the :queries needs to be an array of Hashes with :query set in  
each one.  This allows for inverting the query by adding :negative =>  
true also.

In my example, you get this back in the response:


The key for the 'facet_queries' is the converted Lucene query, with  
parens wrapped around it.  The Flare demo app displays these by  
leveraging the :real_query that gets added under the covers, like this:

<% @flare.facet_queries.each do |name,value|
      count =['facet_counts']['facet_queries'][value 

A bit ugly, indeed, but it works for what it's worth.

> Thanks in advance,

Thank you for giving Flare some attention :)

There is some energy coming to Flare from some other projects,  
notably Blacklight at so I  
think we'll see some patches coming from there soon.


View raw message