2011-05-16 39 views
3

我一直試圖在ApacheSolr中使用ExternalFileField進行外部評分。Apache Solr中的外部文件字段

我正在使用示例配置。基本上我想使用他們的ID設置項目的分數。

我設置的字段類型idRankFile和現場idRank schema.xml中:

<fieldType name="idRankFile" keyField="id" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="pfloat" /> 
<field name="idRank" type="idRankFile" indexed="true" stored="true" /> 

並提出了一個名爲external_idRank在/ Solr的/例子/ Solr的/數據有以下內容的文件:

F8V7067-APL-KIT = 1.0 
IW-02 = 10.0 
9885A004 = 100.0 
SOLR1000 = 1000.0 

(這爲各種ID分配idRank值)

現在我運行以下查詢:

http://localhost:8983/solr/select/?indent=on&q=car%20power%20adapter%20_val_:%22product(idRank,1)%22&fl=name,id

這應該基本上會按照idRanks的順序返回結果。但是,它沒有。

任何想法?

回答

2

好吧,所以我有同樣的問題。這是我做過什麼:

  1. 創建一個文件:
    solr_home/PROJECT/multicore/core1/data/external_popularProducts.txt

    該文件應包含的值是這樣的:
    uniqueID_in_core=count

    例子:
    873728721=19
    842728342=20

  2. 更新schema.xml中,下<types> </types>
    <fieldType name="popularProductsFile" keyField="key" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="float" />

    這裏添加此,key是Solr的核心的primaryID列名。
    添加此下<fields></fields>
    <field name="popularProducts" type="popularProductsFile" indexed="true" stored="true" />

  3. 刷新的核心。我正在使用有bug的solr4.3。當我嘗試重新加載任何內核時,solrcloud節點停止運行。 SOLR-4805: SolrCloud - RELOAD on collections or cores leaves collection offline and unusable till restart。所以,我不得不重新啓動我的solrcloud節點。

  4. 查詢: http://SOLR_NODE:8983/solr/core1/select?q=ipad&sort=popularProducts desc

注:
大多數寫ExternalFileField博客並不完全準確。因此,請參閱原始文檔:

  1. http://lucene.apache.org/solr/4_3_1/solr-core/org/apache/solr/schema/ExternalFileField.html
  2. http://docs.lucidworks.com/display/solr/Working+with+External+Files+and+Processes

請提高這個答案,如果你找到它的任何問題。