On Feb 2, 2007, at 5:29 PM, Yonik Seeley wrote:
On 2/2/07, Michael Kimsal <[EMAIL PROTECTED]> wrote:
I'm having a devil of a time getting date seaching to work
properly. I've
created a 'date' field in my schema, and I put values like
"2005-08-01T23:59:59Z" in it.
However, when I run the following search
foobar date:[2005-08-01T00:00:00Z TO 2005-08-01T23:59:59Z]
I get values back that do not have a date value in the 08/01/2005
range.
Hmmm, we need to get an easy update form committed so this stuff
becomes
easier to test. Anyway, here is a little test program that uses the
python client:
from solr import *
c = SolrConnection(host='localhost:8983')
c.add(id='500',a_dt='2005-08-01T23:59:59Z')
c.commit();
print c.search(q='a_dt:"2005-08-01T23:59:59Z"')
print c.search(q='a_dt:["2005-08-01T00:00:00Z" TO
"2005-08-01T23:59:59Z"]')
Your cute Pythonic example prodded me into creating a solrshell:
$ script/solrshell
> Connection.go("http://localhost:8983/solr", :autocommit=>true) do
|c|
>? c.query("hoss").each {|hit| hit.inspect}
> end
=> [{"score"=>4.1724863, "author_text"=>["Hoss,Dieter,"],
"id"=>"u16686", "title_text"=>["Kanal voll :"]}]
I want to get rid of the Connection.go method, so it'll look more
like this:
Connection('http://localhost:8983/solr', :autocommit => true)
do |c|
# Use real Time object instances instead of these hard-coded
strings, the conversion is already handled
c.add(:id=>'500',:a_dt=>'2005-08-01T23:59:59Z')
puts c.query(:query=>'a_dt:"2005-08-01T23:59:59Z"')
puts c.query(:query=>'a_dt:["2005-08-01T00:00:00Z" TO
"2005-08-01T23:59:59Z"]')
end
Ruby experts - know how I can code Solr::Connection to work like this
without an explicit method? (I'm still a Ruby newbie)
Erik