2012-10-23 149 views
3

我正在嘗試使用solr來獲取單詞的頻率。當我給這個查詢:Solr中的字詞頻率

localSolr/solr/select?q=someQuery&rows=0&facet=true&facet.field=content&wt=xml 

solr給我的頻率像;

<lst name="facet_counts"> 
<lst name="facet_queries"/> 
<lst name="facet_fields"> 
<lst name="content"> 
<int name="word1">24</int> 
<int name="word2">12</int> 
<int name="word3">8</int> 

但是,當我數的話;我發現word2的實際計數值是13.Ssolr統計字段中相同的單詞。

例如;

字段文本包含; word2 word5 word7 word9 word2。 Solr不會返回word2的計數編號2,而是返回1.它將爲下面兩個句子的word2計數返回1;

word2 word10 word11 word12 
word2 word9 word7 word2 word23 

因此頻率返回錯誤。我已經檢查了方面的領域,但沒有找到適當的參數。我該如何解決這個問題,以便它能夠統計句子中的相同單詞?

編輯:schema.xml中的 相關部分:

<fieldType name="text_tr" class="solr.TextField" positionIncrementGap="100"> 
    <field name="content" type="text_tr" stored="true" indexed="true" multiValued="true"/> 
    <copyField source="content" dest="text"/> 
    <field name="text" type="text_tr" stored="false" indexed="true" multiValued="true"/> 

回答

2

如果你刻面在球場上是多值,然後在小的每個字詞都有適當數量

我忘了提一兩件事:在您的查詢需要

Term Vector Component會得到你,tv.tf會給你每個術語的詞頻,而tv.fl告訴SOLR了哪些字段的頻率應計算

NB這使得你的索引時間比現在更慢(又名:你也來試試吧)

+0

感謝您的回答。我改變了字段來使多值參數爲真,但它仍然返回錯誤的答案。 – yns

+0

你可以發佈你的schema.xml,所以也許我可以給你更多的信息? –

+0

對不起,我不能把所有的schema.xml,但我編輯並把相關的部分。我希望它有幫助。 – yns