im trying to find records that are NOT created in a certain date range using a thinking sphinx query in my rails 4 project with postgresql as database
THIS WORKS
Housing.search "some text",
star: true,
ranker: :bm25,
with: {created_at (3.weeks.ago..Time.zone.now)}
BUT THIS DOESN´T
Housing.search "some text",
star: true,
ranker: :bm25,
without: {created_at:(3.weeks.ago..Time.zone.now)}
I´m thinking its a bug in the query since it finds all record within the given date range, but fails to find the opposite?
This is my gemfile
gem 'mysql2', '0.3.12b4'
gem 'thinking-sphinx', github: 'pat/thinking-sphinx'
gem 'flying-sphinx', github: 'flying-sphinx/flying-sphinx'
gem 'delayed_job_active_record', '>= 4.0.0.beta2'
gem 'delayed_job_web'
gem 'ts-delayed-delta', github: 'pat/ts-delayed-delta'
This is my housing_indices
ThinkingSphinx::Index.define :housing, :with => :active_record, :delta => ThinkingSphinx::Deltas::DelayedDelta do
has created_at
< + OTHER FIELDS THAT ARE INDEXED >
set_property :enable_star => true
set_property :min_infix_len => 1
set_property :html_strip => true
set_property :charset_type => "utf-8"
end
this is the query from the log when using without: {created_at:(3.weeks.ago..Time.zone.now)}
Sphinx Query (1.0ms) SELECT * FROM `housing_core`, `housing_delta` WHERE MATCH('@location_name *Krimml*') AND max_capacity BETWEEN 1 AND 1000 AND number_of_bathrooms BETWEEN 1 AND 3 AND number_of_bed_places BETWEEN 2 AND 10 AND sphinx_deleted = 0 AND created_at < 1376554070 OR created_at > 1378368470 AND activated_at <> 0 LIMIT 0, 20 OPTION ranker=bm25
And this Is the error I am getting
sphinxql: syntax error, unexpected OR, expecting $end near 'OR created_at > 1378368470 AND activated_at <> 0 LIMIT 0, 20 OPTION ranker=bm25; SHOW META'
this is the query from the log when using with: {created_at:(3.weeks.ago..Time.zone.now)}
Sphinx Query (3.9ms) SELECT * FROM `housing_core`, `housing_delta` WHERE MATCH('@location_name *Krimml*') AND created_at BETWEEN 1376555152 AND 1378369552 AND max_capacity BETWEEN 1 AND 1000 AND number_of_bathrooms BETWEEN 1 AND 3 AND number_of_bed_places BETWEEN 2 AND 10 AND sphinx_deleted = 0 AND activated_at <> 0 LIMIT 0, 20
so i think what I´m looking for is this query to be executed
AND created_at NOT BETWEEN 1376555152 AND 1378369552