作用
函数查询的作用,是影响计算score的算法,并不替换,只是影响。普通的计算score的方法是lucene本身的算法。
描述如下:
A function query allows you to introduce a component of the score that is computed,
based on a mathematical expression of your choice involving indexed field value(s).
This is not a replacement for Lucene's scoring algorithm, but it basically adds to the
existing score.
可见 函数查询 这个名字并不好,如 《Solr 1.4 Enterprise Search Server》中所述:
A bad name for this feature
The name of this feature is poor as it does not reflect what it does.
Perhaps Scoring Function
or even Score Query
might have been
bette
r. The reason for the name Function Query undoubtedly stems
from the manner in which the feature is implemented. It is implemented
as a Lucene Query type, albeit a very strange one that matches all of the
documents but scores them differently.
本质:
增加一个查询字段,值为函数计算所得。
可以简单这么理解 score += 函数计算结果
本来score是lucene根据字段的查询得到的,比如查询字符串 comments:套餐 lucene根据具体索引情况计算得到score值。
现在模拟一个字段,规定叫做_val_,这个字段的值就是跟随的函数计算的结果。
例子 comments:套餐 && _val_:"div(age,status)"
用法
用法wiki里有好几种,严格来说4种,详细请看wiki。
现在的刚刚发布solr3.1(同步了lucene的版本),这些功能我并没有用过。但1.4中的有些用法有bug。
可以的用法:
q=comments:套餐 && _val_:"div(age,status)"
注意函数就是一个表达式,所以函数也是可以嵌套的~
其他的,不再重复solr的wiki中的内容,仅仅贴出链接。
函数查询的中文翻译版(不太全):http://www.iteye.com/topic/352191
函数查询的wiki版(全而新) :http://wiki.apache.org/solr/FunctionQuery#Using_FunctionQuery
一个好例子,仔细看哦~~ :http://www.ibm.com/developerworks/cn/java/j-spatial/
O
O
O
--
O
O
O
分享到:
相关推荐
详细介绍了Elasticsearch 和 solr 的区别;是一道经典的java面试题
Solr_1.4_Enterprise_Search_Server.pdf
solr_3.5_配置及应用
Solr是一个高性能,采用Java开发,基于Lucene的全文搜索服务器。同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置、可扩展并对查询性能进行了优化,并且提供了一个完善的功能管理界面,是一...
官方推荐读物 Apache_solr_4_cookbook.pdf英文版
solr_5.0_tomcat7_IKAnalyzer中文分词安装步奏及demo演示, 步奏详细可用,配图
solr manageschema 配置文件,增加了分词器后的配置文件
此为solr8的ikanalyzer中文分词包
solr环境搭建所需lib 博客连接http://blog.csdn.net/x631617479/article/details/54232758
solr1.4源码(欢迎喜欢研究solr的人下载)
solr_lxml_示例演示 solr 和 lxml 的 python 代码支持:Mac osx。 Python2.7 & python3.2 lxml 和 yaml 只为 Python2.7 & python3.2 编译示例可执行代码位于:/solr_lxml_Example/server/core 当任何应用程序启动时...
solr
Solr in Action by Trey Grainger , Timothy Potter Book Description Publication Date: April 5, 2014 | ISBN-10: 1617291021 | ISBN-13: 978-1617291029 | Edition: 1 Summary Solr in Action is a ...
一个讲解solr配置和应用demo的文档
solrcloud部署;作者:家和一定万事兴; 参考文章:2014-02-19,于测试机器上部署solrcloud;
solr文档
solr functionquery函数查询功能强大,但字符串函数比较缺乏,该示例是contain示例,表示值中包含传入的字符串即返回1 否则返回0,可用于solr查询中如果某个字段包含动态传入的值在排名优先。有其他查询排序需求...
ik分词器源码,最新版本,支持solr8,及以下版本
solr6.x_IK中文分词工具,solr6.x_IK中文分词工具,solr6.x_IK中文分词工具
在solr使用 IKAnalyzer 分词时,自带的字典比较熟,不适合精确拆分。可以使用sougou分词,还是比较好用的。