【问题标题】:External File Field in Apache SolrApache Solr 中的外部文件字段
【发布时间】:2013-06-27 06:45:59
【问题描述】:

我一直在尝试使用 ApacheSolr 中的 ExternalFileField 进行外部评分。

我正在使用示例配置。基本上我想使用他们的 id 为项目设置分数。

我在schema.xml中设置了fieldType idRankFile和字段idRank:

<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" />

并在 /solr/example/solr/data 中制作了一个名为 external_idRank 的文件,内容如下:

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 的顺序返回结果。但是,事实并非如此。

有什么想法吗?

【问题讨论】:

  • 做了同样的事情,但对我也不起作用,知道缺少什么吗?

标签: solr


【解决方案1】:

好的,所以我遇到了同样的问题。这就是我所做的:

  1. 创建文件:
    solr_home/PROJECT/multicore/core1/data/external_popularProducts.txt

    该文件应包含如下值:
    uniqueID_in_core=count

    示例:
    873728721=19
    842728342=20

  2. 更新schema.xml,在 &lt;types&gt; &lt;/types&gt;下添加这个
    &lt;fieldType name="popularProductsFile" keyField="key" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="float" /&gt;

    这里,key 是 solr core 的 primaryID 的列名。
    将此添加到&lt;fields&gt;&lt;/fields&gt;
    &lt;field name="popularProducts" type="popularProductsFile" indexed="true" stored="true" /&gt;

  3. 重新加载核心。我正在使用有错误的 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&amp;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

如果您发现任何问题,请改进此答案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 2015-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-14
    相关资源
    最近更新 更多