I am using sunspot solr for in my rails app.
I have 2 tables, Table A and Table B. Table A contain ids which appears also in B.
I need to display and perform searches on only only rows found in Table A and not in table B. The searchable attributes are defined as the following in the model.rb:
searchable do
text :bk_id
long :bk_id
long :tableb_bk_id do
tableb.nil?? '' : (tableb.bk_id.nil? ? '' : tableb.bk_id)
end
end
How do I filter the results so that all search and default search return rows with ids found in Table A only and not found in B.
Thanks a lot for your help.
Here are the steps I took to solve the above problem.
Step 1: Find all rows in Table A which need to be excluded
Step 2: Do somethig similar to the following code
post = Post.find(params[:id])
Sunspot.search(Post) do
without(post)
end
The without
clause will exclude the rows you don't want to appear in the resultset.
Hope this is of help to somebody