簡體   English   中英

太陽黑子solr顯示已刪除的文檔

[英]sunspot solr displays deleted documents

我在Ruby-on-Rails應用程序中使用sunspot solr,並將Postgres作為數據庫。 當我更新表中的字段並使用solr搜索結果時,它可以找到舊的索引數據。 例如,我將字段從“測試1”更改為“測試2”,solr可以使用“測試1”查詢來查找文檔,但將其顯示為“測試2”,也可以找到“測試2”。 據我了解,solr在更新文檔時應執行刪除和添加操作,並應跳過所有已刪除的文檔,但是在我的情況下,在請求期間仍顯示已刪除的文檔。

下面是代碼片段:

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

例如,如果我將標題字段從“測試1”更改為“測試2”,我仍然可以找到帶有“測試1”標題的文檔。

非常感謝您的幫助和建議

我發現了問題。 這是對schema.xml文件中的字符串字段進行區分大小寫搜索的配置:

    <fieldType name="string" class="solr.TextField" omitNorms="true">
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

問題仍然懸而未決:如何進行不區分大小寫的搜索,並避免在更新文檔中出現此類問題:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM