Solr:在哪里存储附加信息? [英] Solr: where to store additional information?

查看:19
本文介绍了Solr:在哪里存储附加信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在索引期间为每个被索引的文档提供附加信息.
并在查询期间在同一分析器中访问此信息以进行比较.
所以.从理论上讲,最好将此值写入此文档中存在的某个字段中,并在查询时也搜索此字段.

I want to provide additional information per each indexed document during index time.
And access this information in the same analyzer during query time to compare it.
So. Theoretically it would be great to write this value into some field present in this document and at query time search this field also.

f.e.我有一个动物数据库.我想找到里面有 3 个词狗"的所有文件.(只是一个例子).我可以为我的动物"字段设置我的自定义 BaseTokenFilterFactory,它将生成我的自定义 TokenFilter,它只会计算所有狗"字并将这个数字存储在某个地方.所以.我可以将这个值存储在哪里以便在搜索时访问它?

f.e. I have an animals db. I want to find all documents with 3 words 'dog' inside. (just an example). I can setup for my "animals" field my custom BaseTokenFilterFactory which will produce my custom TokenFilter which will just count all 'dog' words and store this number somewhere. So. Where I can store this value to access it at searching time?

推荐答案

您的示例听起来更适合由 Solr 中的自定义相似性或查询函数处理,而不是作为自定义分析器处理.

Your example sounds like something which will be better suited to be handled by custom Similarity or a query function in Solr and not as a custom analyzer.

例如,如果使用 Solr 4.0,您可以使用函数 termfreq(field,term) 按狗出现的次数排序.或者您可以将其用作过滤器,如下所示:

For example if using Solr 4.0 you can use the function termfreq(field,term) to order by the number of times dog appears. or you can use it as a filter like so:

fq={!frange l=3 u=100000}termfreq(animals,"dog")

这将过滤其animals字段没有至少3次出现单词dog的所有文档.使用这种方法的好处是不影响文档的评分,只过滤文档.

This will filter all documents whose animals field doesn't have at least 3 occurrences of the word dog. The advantage of using this method is that you don't affect the scoring of the documents only filter them.

从 Solr 1.4 开始就存在按函数过滤的功能,因此即使您使用的是早期版本的 Solr (>1.4),您也可以轻松地自己编写termfreq"函数查询

The ability to filter by function exists since Solr 1.4 so even if you are using an earlier version of Solr (>1.4) you can easily write the "termfreq" function query yourself

这篇关于Solr:在哪里存储附加信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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