2013-10-08 23 views
0

我在Solr中有一些文章,並在我的Web應用程序中顯示其詳細信息。在Solr中實現文檔查看計數

我在solrconfig.xml中定義的SearchHandler:

<requestHandler name="/getbyid" class="solr.SearchHandler"> 
    <lst name="defaults"> 
     <str name="echoParams">explicit</str> 
     <str name="wt">json</str> 
     <str name="indent">true</str> 
     <str name="qf">id</str> 
     <str name="df">id</str> 
     <str name="mm">100%</str> 
     <str name="rows">1</str> 
     <str name="fl">*,score</str> 
    </lst> 
    </requestHandler> 

當用戶點擊文檔查看相關詳細說明,我提取使用此處理程序的數據。

我在schema.xml中定義一個字段:

<field name="viewCount" type="int" indexed="false" stored="true" multiValued="false" /> 

當用戶點擊,我使用handler獲取文檔,然後我更新與增加viewCount文檔。

Solr中是否有內置的解決方案來實現文檔的視圖計數?

如果不是,更新viewCount的最佳方法是什麼? (我應該更新的觀看次數和用戶希望看到它每次提交文件)

+0

http://1opensourcelover.wordpress.com/2013/07/02/solr-external-file-fields/ –

回答

2

您無法自動獲取數據時更新。 我知道的最佳解決方案是創建批處理xml命令,然後以特定間隔將xml批處理文件發佈到SOLR服務器。 另外,SOLR 4中還有一些新增功能,比如增量功能,可以在您的場景中使用。