2012-02-20 70 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