主要知识点:

cross-fields 的使用场景

cross-fields 使用方法

cross-fields 的缺点

 
 

一、cross-fields 的使用场景

 
 

cross-fields搜索,一个唯一标识可能存在于多个field。比如一个人的标识是姓名;一个建筑的标识是地址。姓名可以分步在多个field中,比如first_name和last_name中,地址可以分步在country,province,city中。此时做标识符搜索的话就必须跨多个field搜索同一个标识,比如搜索一个人名,或者一个地址,这就是cross-fields搜索。初步来说,如果要实现cross-fields,用most_fields比较合适。因为best_fields是优先搜索单个field最匹配的结果,cross-fields本身就不是一个field的问题了。

 
 

二、cross-fields 使用方法

1、准备数据

 
 

POST /forum/article/_bulk

{ "update": { "_id": "1"} }

{ "doc" : {"author_first_name" : "Peter", "author_last_name" : "Smith"} }

{ "update": { "_id": "2"} }

{ "doc" : {"author_first_name" : "Smith", "author_last_name" : "Williams"} }

{ "update": { "_id": "3"} }

{ "doc" : {"author_first_name" : "Jack", "author_last_name" : "Ma"} }

{ "update": { "_id": "4"} }

{ "doc" : {"author_first_name" : "Robbin", "author_last_name" : "Li"} }

{ "update": { "_id": "5"} }

{ "doc" : {"author_first_name" : "Tonny", "author_last_name" : "Peter Smith"} }

 
 

2、进行搜索

GET /forum/article/_search

{

"query": {

"multi_match": {

"query": "Peter Smith",

"type": "most_fields",

"fields": [ "author_first_name", "author_last_name" ]

}

}

}

 
 

执行结果

 
 

{

"took": 2,

"timed_out": false,

"_shards": {

"total": 5,

"successful": 5,

"failed": 0

},

"hits": {

"total": 3,

"max_score": 0.6931472,

"hits": [

{

"_index": "forum",

"_type": "article",

"_id": "2",

"_score": 0.6931472,

"_source": {

"articleID": "KDKE-B-9947-#kL5",

"userID": 1,

"hidden": false,

"postDate": "2017-01-02",

"tag": [

"java"

],

"tag_cnt": 1,

"view_cnt": 50,

"title": "this is java blog",

"content": "i think java is the best programming language",

"sub_title": "learned a lot of course",

"author_first_name": "Smith",

"author_last_name": "Williams"

}

},

 

三、cross-fields 的缺点

1、只是找到尽可能多的field匹配的doc,而不是某个field完全匹配的doc

2、most_fields,没办法用minimum_should_match去掉长尾数据,就是匹配的特别少的结果

3、TF/IDF算法的计算可能和我们预期有差异,比如Peter Smith和Smith Williams,搜索Peter Smith的时候,由于first_name中很少有Smith的,所以query在所有document中的频率很低,得到的分数很高,可能Smith Williams反而会排在Peter Smith前面。

15.most_fields策略进行cross-fields search的更多相关文章

  1. Elasticsearch跨集群搜索(Cross Cluster Search)

    1.简介 Elasticsearch在5.3版本中引入了Cross Cluster Search(CCS 跨集群搜索)功能,用来替换掉要被废弃的Tribe Node.类似Tribe Node,Cros ...

  2. Elasticsearch 搜索模块之Cross Cluster Search(跨集群搜索)

    Cross Cluster Search简介 cross-cluster search功能允许任何节点作为跨多个群集的federated client(联合客户端),与tribe node不同的是cr ...

  3. ES cross cluster search跨集群查询

    ES 5.3以后出的新功能.测试demo如下: 下载ES 5.5版本,然后分别本机创建2个实例,配置如下: cluster.name: xx1 network.host: 127.0.0.1 http ...

  4. Elasticsearch搜索之cross_fields分析

    cross_fields类型采用了一种以词条为中心(Term-centric)的方法,这种方法和best_fields及most_fields采用的以字段为中心(Field-centric)的方法有很 ...

  5. Elasticsearch学习之深入搜索三 --- best fields策略

    1. 为帖子数据增加content字段 POST /forum/article/_bulk { "} } { "doc" : {"content" : ...

  6. Kibana中doc与search策略的区别

    在kibana中包含两种策略:doc和search.使用了两个循环队列来获取请求,并进行响应. doc的代码如下: clientMethod: 'mget' search的代码如下: clientMe ...

  7. ElasticSearch 2 (15) - 深入搜索系列之多字段搜索

    ElasticSearch 2 (15) - 深入搜索系列之多字段搜索 摘要 查询很少是简单的一句话匹配(one-clause match)查询.很多时候,我们需要用相同或不同的字符串查询1个或多个字 ...

  8. 白日梦的Elasticsearch实战笔记,ES账号免费借用、32个查询案例、15个聚合案例、7个查询优化技巧。

    目录 一.导读 二.福利:账号借用 三._search api 搜索api 3.1.什么是query string search? 3.2.什么是query dsl? 3.3.干货!32个查询案例! ...

  9. 白日梦的Elasticsearch实战笔记,32个查询案例、15个聚合案例、7个查询优化技巧。

    目录 一.导读 三._search api 搜索api 3.1.什么是query string search? 3.2.什么是query dsl? 3.3.干货!32个查询案例! 四.聚合分析 4.1 ...

随机推荐

  1. mysql安装后改动port号password默认字符编码

    1.改动password grant all privileges on *.* to 'root'@'localhost' identified by 'new password'; 2.改动por ...

  2. linux设备驱动模型之Kobject、kobj_type、kset【转】

    本文转载自:http://blog.csdn.net/fengyuwuzu0519/article/details/74838165 版权声明:本文为博主原创文章,转载请注明http://blog.c ...

  3. 利用POI抽取word中的图片并保存在文件中

    利用POI抽取word中的图片并保存在文件中 poi.apache.org/hwpf/quick-guide.html 1.抽取word doc中的图片 package parse; import j ...

  4. CF732 F Tourist Reform——边双连通分量

    题目:http://codeforces.com/contest/732/problem/F 首先把边双缩点,边双内部 dfs 一个顺序一定是可以从每个点走到边双内部所有点的,因为它是以环为基本单位: ...

  5. Java Swing Action 动作

    Swing包提供了一种非常实用的机制来封装命令,并将它们连接到多个事件源,这就是Action接口.一个动作是一个封装下列内容的对象: × 命令的说明(一个文本字符串和一个可选图标): × 执行命令所需 ...

  6. 杂项:BPM

    ylbtech-杂项:BPM 1.返回顶部 1. BPM,即业务流程管理,是一种以规范化的构造端到端的卓越业务流程为中心,以持续的提高组织业务绩效为目的的系统化方法,常见商业管理教育如EMBA.MBA ...

  7. 自动生成Makefile的全过程详解

    一.简介 Linux下的程序开发人员,一定都遇到过Makefile,用make命令来编译自己写的程序确实是很方便.一般情况下,大家都是手工写一个简单Makefile,如果要想写出一个符合自由软件惯例的 ...

  8. MySQL 1366错误解决办法

    MySQL 1366错误大致描述如下 SQL Error: 1366: Incorrect string value: "xE8xAFxA6xE7xBBx86-" for colu ...

  9. Java开源JSP标签库

    01displytag 与Struts结合使用最出名的一个tag主要是显示表格数据很漂亮.完善. 02cewolf tag 用来在web上显示复杂图形报表的一个jsp tag. 03Loading T ...

  10. $CF41D\ Pawn$

    \(problem\) 与这题 灰常的相似 然后内存可能过大 开个滚动数组 因为数塔问题总是 只需要上面一行的两个状态(这题就是数塔问题) 下面的代码与原题不符.(原题要输出路径)想抄的可以走了 输出 ...