2012-02-20 71 views
1

我想知道是否有任何事情可以幫助改善我用solr看到的搜索結果。使用solr +太陽黑子提高搜索結果

我有一個帶有「The Glenlivet 18 year」值的文本字段「name」的產品模型。

我有我的產品型號此搜索塊:

searchable do 
    text :name 
end 

當我搜索「該格倫利威單一麥芽蘇格蘭18歲750ML」,我得到的結果爲零。

1.9.3-p0 :001 > Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML"}.results 
=> [] 

這似乎是我必須真正煮沸搜索查詢才能得到一個結果,這不是很有用。

1.9.3-p0 :002 > Product.search { fulltext "The Glenlivet 18 Yr. 750ML"}.results 
=> [] 

1.9.3-p0 :006 > Product.search { fulltext "The Glenlivet Single Malt 18"}.results 
=> [] 

它真的像這樣的接縫工作。

1.9.3-p0 :003 > Product.search { fulltext "The Glenlivet 18 Yr."}.results 
=> [] 

後來終於

1.9.3-p0 :007 > Product.search { fulltext "Glenlivet 18"}.results 
Product Load (0.2ms) SELECT `products`.* FROM `products` WHERE `products`.`id` IN (8) 
=> [#<Product id: 8, name: "The Glenlivet 18 year"] 

它在該sunspot_solr寶石創建Solr的所有默認設置。下面是我的配置文件:

有了這些樣的結果它幾乎擊敗了全文搜索的目的。有沒有我可以調整的設置或我可以做的其他事情,以便這些結果看起來並不嚴格?

編輯:

添加:minimum_match => 4並設置同義詞似乎提供我想要的結果。

Product.search { fulltext "The Glenlivet Single Malt Scotch 18 Yr. 750ML", :minimum_match => 4}.results 
+0

你可以從'schema.xml'發佈全文字段的定義和fieldType嗎? – javanna 2012-02-20 11:49:47

+0

我添加了我的schema.xml http://pastebin.com/53ryHT6H – AdamB 2012-02-20 20:18:57

回答

1

確保您fullext場被視爲文本,然後不是字符串看最低匹配設置:

http://wiki.apache.org/solr/DisMaxQParserPlugin#mm_.28Minimum_.27Should.27_Match.29

此外,您可能需要同義詞等同一年年。

+0

我在哪裏可以找到該設置?我試着只添加同義詞「yr => year」,而我仍然用「Product.search {fulltext」The Glenlivet 18 yr「}。results」得到零結果。我確保重新啓動solr,並且每當我更改synonyms synonym.txt時重新索引。 – AdamB 2012-02-20 20:23:47

+0

毫米將被設置爲solrconfig中dismax查詢處理程序的一部分。 – 2012-02-20 21:05:43

+1

您需要在索引或查詢時間配置同義詞過濾器因子。該類的信息在這裏:http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory – 2012-02-20 21:07:43