得分以及高光在搜索引擎中有很重要的作用

得分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 得分以及高光的更多相关文章

  1. 软件工程(FZU2015)赛季得分榜,第一回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  2. 软件工程(FZU2015)赛季得分榜,第二回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  3. 软件工程(FZU2015)赛季得分榜,第三回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  4. 软件工程(FZU2015)赛季得分榜,第四回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  5. 软件工程(FZU2015)赛季得分榜,第五回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  6. 软件工程(FZU2015)赛季得分榜,第六回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  7. 软件工程(FZU2015)赛季得分榜,第七回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  8. 软件工程(FZU2015)赛季得分榜,第八回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

  9. 软件工程(FZU2015)赛季得分榜,第9回合

    目录 第一回合 第二回合 第三回合 第四回合 第五回合 第6回合 第7回合 第8回合 第9回合 第10回合 第11回合 积分规则 积分制: 作业为10分制,练习为3分制:alpha30分: 团队项目分 ...

随机推荐

  1. Selenium(基于JAVA语言)-》在eclipse上运行web项目在Mac系统上启动时提示nodename nor servname provided解决办法

    最近使用eclipse进行自动化测试时,遇到一种情况,无法调起浏览器,且有报错,如下: org.openqa.selenium.WebDriverException: failed to lookup ...

  2. 绑定方法与非绑定方法 classmethod和staticmethod

    一:绑定方法:特点:绑定给谁就应该是由谁来调用,谁来调用就会将谁当做第一个参数传入 1:绑定给对象的方法:类中定义的函数默认就是绑定给对象的 例:        2:绑定给类的方法:为类中定义的函数加 ...

  3. python 获取subprocess进程执行后返回值

    test.py #coding=utf- import subprocess compilePopen = subprocess.Popen('gcc haha',shell=True,stderr= ...

  4. idea提示不区分大小写,解决方法

  5. yii2常用路径获取

    public function actionGetUrlList() { echo "当前域名地址:".Yii::$app->request->hostInfo.&qu ...

  6. python学习(五)

  7. 『计算机视觉』R-FCN:Object Detection via Region-based Fully Convolutional Networks

    一.网络介绍 参考文章:R-FCN详解 论文地址:Object Detection via Region-based Fully Convolutional Networks R-FCN是Faster ...

  8. js禁止页面滚动

    开发移动端页面的时候有一个很比较常见的需求,在出现弹窗时,禁止滑动弹窗后面的主体页面.如何实现呢,往下看 js实现整个页面禁止滚动: document.body.addEventListener('t ...

  9. K-临近算法(KNN)

    K-临近算法(KNN) K nearest neighbour 1.k-近邻算法原理 简单地说,K-近邻算法采用测量不同特征值之间的距离方法进行分类. 优点:精度高.对异常值不敏感.无数据输入假定. ...

  10. CRM SALES ORDER ADD EEWB SEARCH FIELD

    1.找到对应的查询结构: T-code:GENIL_MODEL_BROWSER Component Set 输入'ONEORDER' 点击DISPLAY 展开Dynamic Query Object, ...