2011-05-16 77 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

请提高这个答案,如果你找到它的任何问题。