Return-Path: Delivered-To: apmail-lucene-ruby-dev-archive@www.apache.org Received: (qmail 51543 invoked from network); 22 Jan 2008 03:38:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jan 2008 03:38:17 -0000 Received: (qmail 77098 invoked by uid 500); 22 Jan 2008 03:38:07 -0000 Delivered-To: apmail-lucene-ruby-dev-archive@lucene.apache.org Received: (qmail 77081 invoked by uid 500); 22 Jan 2008 03:38:07 -0000 Mailing-List: contact ruby-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ruby-dev@lucene.apache.org Delivered-To: mailing list ruby-dev@lucene.apache.org Received: (qmail 77070 invoked by uid 99); 22 Jan 2008 03:38:07 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jan 2008 19:38:07 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [69.55.225.129] (HELO ehatchersolutions.com) (69.55.225.129) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jan 2008 03:37:53 +0000 Received: by ehatchersolutions.com (Postfix, from userid 504) id 009C430EFC26; Mon, 21 Jan 2008 20:37:44 -0700 (MST) X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on javelina X-Spam-Level: Received: from [10.0.1.2] (va-71-53-211-181.dyn.embarqhsd.net [71.53.211.181]) by ehatchersolutions.com (Postfix) with ESMTP id B44CD30EFC27 for ; Mon, 21 Jan 2008 20:37:38 -0700 (MST) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: <4788EAE8.2000807@r.email.ne.jp> References: <4788EAE8.2000807@r.email.ne.jp> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <5FADF877-DC43-4865-A3A8-ACB026F13A9C@ehatchersolutions.com> Content-Transfer-Encoding: 7bit From: Erik Hatcher Subject: Re: solr-ruby - qt parameter with Dismax.rb Date: Mon, 21 Jan 2008 22:36:39 -0500 To: ruby-dev@lucene.apache.org X-Mailer: Apple Mail (2.752.3) X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-0.7 required=5.0 tests=AWL,BAYES_00, RCVD_IN_SORBS_DUL autolearn=no version=3.1.1 Koji, My apologies for the belated reply. On Jan 12, 2008, at 11:29 AM, Koji Sekiguchi wrote: > I have the following request handler defined in solrconfig.xml: > > > > explicit > 0.01 > > body body_exact^2.0 > > > id,body,score > > *:* > on > body > 0 > body > > > > To use the request handler, I'd like to specify qt=demo for Dismax.rb. > However, I cannot find how to do it. Here's the trick, to benefit from the parameter handling that Solr::Request::Dismax offers: class DemoRequest < Solr::Request::Dismax def initialize(params) super @query_type = "demo" end end and even a unit test :) def test_demo f = DemoRequest.new(:query => "whatever") assert_equal("demo", f.query_type) end Further, in general you can use solr-ruby's Solr::Connection#post method to call into most any Solr request handler, just adhering to the duck quacking that given here: def post(request) response = @connection.post(@url.path + "/" + request.handler, request.to_s, { "Content-Type" => request.content_type }) case response when Net::HTTPSuccess then response.body else response.error! end end So as long as the "request" object has #handler, #to_s, and #content_type methods. You can see how these work with the simple Solr::Request::Base and Solr::Request::Select classes. One nagging issue I have with the current solr-ruby design is with the Connection#send method, which requires parallel Request and Response classes, but if you want to build your own very simple request/response classes you could use Connection#send even easier. Sorry if that last bit of trivia was too much (confusing) information - I just wanted to toss that out to show that it's actually not too much coding to do these custom requests to Solr. I definitely can see making solr-ruby more amenable to your "demo"- like scenarios, as mapping custom request handlers in Solr is really the way to go for many reasons. Erik