I'm using sunspot solr in the Ruby-on-Rails application with Postgres as a database. When I update a field in the table and search for results with solr it can find old index data. For example, I changed the field from “Test 1” to “Test 2” and solr can find a document with “Test 1” query, but displays it as “Test 2”, also it can find “Test 2”. As I understand solr while updating document should perform delete and add operations and should skip all deleted documents but in my case deleted documents still display during requests.
Below is code snippet:
class Position < ActiveRecord::Base
........
searchable ignore_attribute_changes_of: [ :sha1hash ] do
text :title
text :description
text :account_location do
account.address.entire_address if account.address
end
text :account_name do
account.name
end
string :title
............
end
def search_index()
..............
Position.search(include: [{ account: :address }]) do |query|
query.without(:private, true)
query.with(:unconfirmed_account, false)
query.with(:account_name, params[:name]) if params[:name].present?
query.with(:title, params[:title]) if params[:title].present?
..............
query.paginate per_page: per_page, page: [params[:page].to_i, 1].max
end
end
For example, if I changed a title field from "Test 1" to "Test 2" I can still find document with "Test 1" title.
Thanks very much for your help and advice
Test, depending on the query operator). - MatsLindh