zombodb 得分以及高光
得分以及高光在搜索引擎中有很重要的作用
得分zdb.score
- 使用方法
zdb.score(tid)
- 参考示例
SELECT zdb.score(ctid), *
FROM products
WHERE products ==> 'sports box'
ORDER BY score desc;
结果:
score | id | name | keywords | short_summary | long_description | price | inventory_count | discontinued | availability_date
----------+----+----------+--------------------------------------+--------------------------------+-------------------------------------------------------------------------------------+-------+-----------------+--------------+-------------------
1.06561 | 4 | Box | {wooden,box,"negative space",square} | Just an empty box made of wood | A wooden container that will eventually rot away. Put stuff it in (but not a cat). | 17000 | 0 | t | 2015-07-01
0.723777 | 2 | Baseball | {baseball,sports,round} | It's a baseball | Throw it at a person with a big wooden stick and hope they don't hit it | 1249 | 2 | f | 2015-08-21
(2 rows)
- 说明
对于进行使用得分进行需要使用dsl 的dsl.min_score()
高光highlight 函数
- 方法签名
zdb.highlight(tid, fieldname [, json_highlight_descriptor]) RETURNS text[]
- 使用
SELECT zdb.score(ctid), zdb.highlight(ctid, 'long_description'), long_description
FROM products
WHERE products ==> 'wooden person'
ORDER BY score desc;
结果:
score | highlight | long_description
----------+--------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------
0.914156 | {"Throw it at a <em>person</em> with a big <em>wooden</em> stick and hope they don't hit it"} | Throw it at a person with a big wooden stick and hope they don't hit it
0.243605 | {"A <em>wooden</em> container that will eventually rot away. Put stuff it in (but not a cat)."} | A wooden container that will eventually rot away. Put stuff it in (but not a cat).
(2 rows)
自定义高光函数编写
主要是基于zdb 提供的函数
- 官方提供的一个高光函数
CREATE TYPE esqdsl_highlight_type AS ENUM ('unified', 'plain', 'fvh');
CREATE TYPE esqdsl_fragmenter_type AS ENUM ('simple', 'span');
CREATE TYPE esqdsl_encoder_type AS ENUM ('default', 'html');
CREATE TYPE esqdsl_boundary_scanner_type AS ENUM ('chars', 'sentence', 'word');
FUNCTION highlight(
type zdb.esqdsl_highlight_type DEFAULT NULL,
require_field_match boolean DEFAULT false,
number_of_fragments int DEFAULT NULL,
highlight_query zdbquery DEFAULT NULL,
pre_tags text[] DEFAULT NULL,
post_tags text[] DEFAULT NULL,
tags_schema text DEFAULT NULL,
no_match_size int DEFAULT NULL,
fragmenter zdb.esqdsl_fragmenter_type DEFAULT NULL,
fragment_size int DEFAULT NULL,
fragment_offset int DEFAULT NULL,
force_source boolean DEFAULT true,
encoder zdb.esqdsl_encoder_type DEFAULT NULL,
boundary_scanner_locale text DEFAULT NULL,
boundary_scan_max int DEFAULT NULL,
boundary_chars text DEFAULT NULL,
phrase_limit int DEFAULT NULL,
matched_fields boolean DEFAULT NULL,
"order" text DEFAULT NULL)
RETURNS json
- 使用
SELECT zdb.score(ctid),
zdb.highlight(ctid,
'long_description',
zdb.highlight(pre_tags=>'{<b>}', post_tags=>'{</b>}')
),
long_description
FROM products
WHERE products ==> 'wooden person'
ORDER BY score desc;
score | highlight | long_description
----------+------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------
0.914156 | {"Throw it at a <b>person</b> with a big <b>wooden</b> stick and hope they don't hit it"} | Throw it at a person with a big wooden stick and hope they don't hit it
0.243605 | {"A <b>wooden</b> container that will eventually rot away. Put stuff it in (but not a cat)."} | A wooden container that will eventually rot away. Put stuff it in (but not a cat).
(2 rows)
参考资料
https://github.com/zombodb/zombodb/blob/master/SCORING-HIGHLIGHTING.md
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html
zombodb 得分以及高光的更多相关文章
- 软件工程(FZU2015)赛季得分榜,第一回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第二回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第三回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第四回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第五回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第六回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第七回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第八回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
- 软件工程(FZU2015)赛季得分榜,第9回合
目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...
随机推荐
- 使用java命令运行class文件提示“错误:找不到或无法加载主类“的问题分析
有时候我们需要直接用jdk提供的java命令来执行class文件让软件运行起来,特别是很多初学者,但经常会发现如下提示: 用eclipse或用ant则没有问题. 其实原因很简单,我们忽略了2个细节. ...
- cmd 查看端口
windows + R 调出cmd窗口 输入 netstat -nao 查看端口使用情况 输入netstat -nao | findstr 80查找指定端口 杀死指定端口的进程taskkill /pi ...
- Java版 人脸识别SDK dem
虹软人脸识别SDK之Java版,支持SDK 1.1+,以及2.0版本,滴滴,抓紧上车! 前言由于业务需求,最近跟人脸识别杠上了,本以为虹软提供的SDK是那种面向开发语言的,结果是一堆dll······ ...
- echarts之折线图配置(附带图例很多做成分页效果)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 『TensorFlow』分类问题与两种交叉熵
关于categorical cross entropy 和 binary cross entropy的比较,差异一般体现在不同的分类(二分类.多分类等)任务目标,可以参考文章keras中两种交叉熵损失 ...
- selenium java 文件上传、下载
1.webdriver对页面文件的下载 我们一般操作浏览器下载时会让我们选择下载的目录然后经过一系列操作后才进行文件下载操作,但是用webdriver不能按这样的方式操作.经过查询资料找到了如下的实现 ...
- XXX系统业务建模
1.识别业务参与者 参与者包括管理员.填报人员.审核人员和领导. 2.识别业务用例(用例图展现) 3.详述业务用例(填报需求这一用例,以活动图详细展现如下) 4.建立业务对象模型
- [Leetcode 46]全排列 Permutations 递归
[题目] Given a collection of distinct integers, return all possible permutations. 数组的组合情况. Input: [1,2 ...
- 一个神奇的???whatever~~
一个神奇的类,用来封装消息数据,统一数据传递接口,从unity引擎源码拷贝而来. #include <iostream> #include <assert.h> #includ ...
- CSS图形——实现圆角
css实现圆角 css2.1给元素添加圆角是一件很麻烦的事,老办法是用背景图片实现,制作比较麻烦.css3,border-radius的属性,使圆角属性得到完美的解决. 语法 border-radiu ...