Koji,

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 session.

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]
@flare.page = params[:page].to_i
end

@start = (@flare.page - 1) * @results_per_page

@response = @flare.search(@start, @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 facet_queries:

  def index
@flare.facet_queries = {"foo"=>{:filters=>[], :queries=> [{:query=>"whatever"}]}}
    @response = @flare.search(@start, @results_per_page)
  end

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:

   'facet_counts'=>{'facet_queries'=>{'(whatever)'=>4}

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 = @response.data['facet_counts']['facet_queries'][value [:real_query]]
%>

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 http://blacklight.betech.virginia.edu so I think we'll see some patches coming from there soon.

        Erik

Reply via email to