Martin Grotzke wrote:
On Tue, 2007-06-26 at 23:22 -0700, Chris Hostetter wrote:
: So if it would be possible to go over each item in the search result
: I could check the price field and define my ranges for the specific
: query on solr side and return the price ranges as a facet.
: Otherwise, what would be a good starting point to plug in such
: functionality into solr?
if you relaly want to do statistical distributions, one way to avoid doing
all of this work on the client side (and needing to pull back all of hte
prices from all of hte matches) would be to write a custom request handler
that subclasses whichever on you currently use and does this computation
on the server side -- where it has lower level access to the data and
doesn't need to stream it over the wire. FieldCache in particular would
come in handy.
Now we want to have fun with statistics and calculation, and I just set
up a new project with a dependency on apache-solr-1.2.0. I started a
RangeRequestHandler extending StandardRequestHandler, but I don't really
see where to plug in. Most probably it's the handleRequestBody, but
there's a lot of stuff in StandardRequestHandler.handleRequestBody that
I do not want to repeat...
For now, if you want to integrate existing standard/dismax
functionality, there is no great way to cleanly do this without copying
the code. There is discussion of 'search components' that will let you
customize single parts of the search pipeline -- in your case faceting
-- but this is still a ways off.
You could almost do what you need by overriding getFacetInfo(), but you
also need to check the DocList.
To ask a question: how could I get each document of the result to
check the price and do some calculation at the end?
With a DocList, you can cycle through the matched documents using:
IndexReader reader = core.getSearcher().get().getReader();
System.out.println("response.size() = " + docs.size());
DocIterator iter = docs.iterator();
while (iter.hasNext()) {
Document doc = reader.document(iter.next());
System.out.println("doc = " + doc);
}
ryan