Hello,

It worked changing the format too %Y%m%d.  So, Ruby does not really  
handle dates directly?  I would have thought Ferret would have parsed  
the Date object internally.  Anyways, thanks for the help!

Benjamin

On Jan 11, 2008, at 1:26 PM, John Leach wrote:

> On Fri, 2008-01-11 at 11:14 -0800, Benjamin Arai wrote:
>> Hello,
>>
>> I am having trouble getting data ranges to work correctly.  I am  
>> using
>> the following command to load the db:
>>
>
> Hi Benjamin,
>
> the .to_s method for the Date object returns a date formatted like
> "2007-12-25, so for one you're searching for a string that doesn't  
> exist
> in the index.
>
> Secondly, I'm pretty sure the hypens in that string will be  
> tokenized by
> the Ferret tokenizer, so will end up in the database as separate  
> parts,
> so a range query would be slow (or not work, not certain).
>
> Try explicitly returning the date in a useful format when putting it  
> in
> the index:
>
> index << {:title => row[7].to_i,
>                :date => Date.strptime(row[3], '%Y-%m- 
> %d').strftime("%Y%m%d"),
>                :page_id => row[5].to_i,
>                :page => row[6].to_i,
>                :content_type => row[1].to_i,
>                :article_id => row[4].to_i,
>                :label => row[2],
>                :label_sort => row[8],
>                :content => row[0]
>               }
> John
> -- 
> http://www.brightbox.co.uk - UK Ruby on Rails hosting
>
>
>> index << {:title => row[7].to_i,
>>                :date => Date.strptime(row[3], '%Y-%m-%d'),
>>                :page_id => row[5].to_i,
>>                :page => row[6].to_i,
>>                :content_type => row[1].to_i,
>>                :article_id => row[4].to_i,
>>                :label => row[2],
>>                :label_sort => row[8],
>>                :content => row[0]
>>               }
>>
>> Notice "Date.strptime(row[3], '%Y-%m-%d')"...
>>
>> When I query (ex. +label:barbara) I get results in the form:
>>
>> {:label=>"NEW TOOL FOR BARBERS.", :page_id=>"36", :label_sort=>"NEW  
>> TOOL
>> FOR BARBERS.", :page=>"4", :date=>"1900-03-02", :content_type=>"19",
>> :title=>"1", :article_id=>"7855", :content=>" NEW TOOL FOR BARBERS."}
>> ...
>>
>> Which looks correct to me but if I modify the query to include a date
>> range like "+label:barbara +data:{19000101 19010101}" or even
>> "+label:barbara +data:(>=19000101 AND <= 19010101}" I get 0 results.
>> Does anybody know what I am doing incorrectly?
>>
>> I am using Windows Vista, Ferret version 0.11.5 mswin32.
>>
>> Benjamin
>
>
> _______________________________________________
> Ferret-talk mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/ferret-talk
>

_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to