Apache Solr 中的外部文件字段 [英] External File Field in Apache Solr

查看:23
本文介绍了Apache Solr 中的外部文件字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've been trying to use ExternalFileField in ApacheSolr for external scoring.

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

I'm using the example config. Basically I want to set scores for items using their ids.

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

I set the fieldType idRankFile and field idRank in 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" />

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

And made a file called external_idRank in /solr/example/solr/data with the following content:

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

(这会为各种 id 分配 idRank 值)

(This assigns idRank values for various ids)

现在我运行以下查询:

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

这应该基本上按照 idRank 的顺序返回结果.然而,事实并非如此.

This should basically return the results in order of their idRanks. However, it does not.

有什么想法吗?

推荐答案

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

Alright, so I had the same problem. This is what I did:

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

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

示例:
873728721=19
842728342=20

更新schema.xml,在 下添加这个</types>

Update schema.xml, add this under <types> </types>
<fieldType name="popularProductsFile" keyField="key" defVal="0" stored="true" indexed="true" class="solr.ExternalFileField" valType="float" />

这里,key是solr core的primaryID的列名.

下添加

Here, key is the column name for the primaryID of solr core.
Add this under <fields></fields>
<field name="popularProducts" type="popularProductsFile" indexed="true" stored="true" />

重新加载内核.我正在使用有错误的 solr4.3.当我尝试重新加载任何核心时,solrcloud 节点出现故障.SOLR-4805:SolrCloud - 集合或核心上的重新加载使集合离线且无法使用,直到重新启动 .所以,我不得不重新启动我的 solrcloud 节点.

Reload the core. I am using solr4.3 which has a bug. When I try to reload any core,the solrcloud node goes down. SOLR-4805: SolrCloud - RELOAD on collections or cores leaves collection offline and unusable till restart . So, I had to restart my solrcloud nodes.

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

注意:
大多数关于 ExternalFileField 的博客都不完全准确.所以只需参考原始文档:

Note:
Most of the blogs written about ExternalFileField are not completely accurate. So just refer to the original documentation:

  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

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

Please improve this answer if you find any issues with it.

这篇关于Apache Solr 中的外部文件字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆