Hi,
yes, as Shay says, dates behave differently. You still can use * as
wildcard, though. Also, double check the mapping for the field in
question. Full example below:
require 'rubygems'
require 'tire'
Tire.index 'events-test-dates' do
delete
create :mappings => {
:event => {
:properties => {
:started_at => { :type => 'date' }
}
}
}
store :event, { :id => 1, :started_at => "2010-01-01" }
store :event, { :id => 2, :started_at => "2011-01-01" }
store :event, { :id => 3, :started_at => "2011-01-02" }
store :event, { :id => 4, :started_at => "2011-02-01" }
store :event, { :id => 5, :started_at => "2011-03-01" }
refresh
end
s = Tire.search 'events-test-dates' do
query { string 'started_at:[2011 TO *]' }
sort { started_at }
end
puts s.to_curl
puts s.results.map(&:started_at).inspect
On May 17, 11:29 am, khoan huukhoangu...@hotmail.com wrote:
Hi,
I'm indexing a Mongoid record via Tire gem. I'm having trouble searching for
dates. Excerpt below:
% curl -XPOSThttp://localhost:9200/events/_search?pretty=true-d
'{"query":{"query_string":{"query":"started_at: *"}}}'
=> ... hits ...
{
"_index" : "events",
"_type" : "event",
"_id" : "4dd22cd5f96f36e6b900027a",
"_score" : 1.0, "_source" :
{"created_at":"2011-05-17T08:07:49Z","started_at":"2011-05-22T16:40:00+00:0 0","updated_at":"2011-05-17T08:07:49Z","url":null,"id":"4dd22cd5f96f36e6b90 0027a"},
"sort" : [ 1.0, 1306082400000 ]
} ...
But when I try to do a "like" search:
% curl -XPOSThttp://localhost:9200/events/_search?pretty=true-d
'{"query":{"query_string":{"query":"started_at: 2011*"}}}'
=> {
"took" : 24,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" :
}
Any pointer is greatly appreciated.
--
View this message in context:http://elasticsearch-users.115913.n3.nabble.com/Mongoid-Tire-date-sea...
Sent from the Elasticsearch Users mailing list archive at Nabble.com.