
Elasticsearch进阶
tianlan996
这个作者很懒,什么都没留下…
展开
-
一 term filter搜索
1. 插入数据: POST /forum/article/_bulk { "index": { "_id": 1 }} { "articleID" : "XHDK-A-1293-#fJ3", "userID" : 1, "hidden": false, "postDate": "2017-01-01" } { "index": { "_id": 2 }} { "articleID" : "KDK...原创 2019-07-19 00:04:57 · 276 阅读 · 0 评论 -
二 bitset与caching机制
1. 对于document中的每一个filed,均建立一个bitset,其中存放的值为0(在文档中不存在)和1(在文档中存在)。 例如,有6个文档,id和date是其中的两个filed,对于这两个filed分别建立bitset: id:[0, 1, 0, 1, 0, 1] --- id为1的值在第2、4、6个文档中存在。 date:[0, 0, 1, 1, 0, 0] ---日期为2019-...原创 2019-07-22 23:32:12 · 181 阅读 · 0 评论 -
三 查询案例
一 结构化搜索_在案例中实战基于bool组合多个filter条件来搜索数据 1、搜索发帖日期为2017-01-01,或者帖子ID为XHDK-A-1293-#fJ3的帖子,同时要求帖子的发帖日期绝对不为2017-01-02 select * from forum.article where (post_date='2017-01-01' or article_id='XHDK-A-1293-#f...原创 2019-08-12 20:13:37 · 203 阅读 · 0 评论 -
四 match的底层实现转化
1、普通match如何转换为term+should { "match": { "title": "java elasticsearch"} } 使用诸如上面的match query进行多值搜索的时候,es会在底层自动将这个match query转换为bool的语法 bool should,指定多个搜索词,同时使用term query { "bool": { "should...原创 2019-08-28 20:27:00 · 366 阅读 · 0 评论 -
五 boost条件权重控制
默认情况下,搜索条件的权重都是一样的,都是1 搜索条件的权重,boost,可以将某个搜索条件的权重加大,此时当匹配这个搜索条件和匹配另一个搜索条件的document,计算relevance score时,匹配权重更大的搜索条件的document,relevance score会更高,当然也就会优先被返回回来 GET /forum/article/_search { "query": { ...原创 2019-08-28 20:38:06 · 611 阅读 · 0 评论 -
六 多shard场景下relevance score不准确原因
shard中只有一部分的document,默认情况下,IDF是在shard本地计算的。 在一个shard中,有多个title中包含Java的document,比如10个。当一个搜索title中包含Java当请求到这个shard到时候,会使用TD/IDF算法: 1. 在一个document到title中,Java出现到次数。 2. 在所有document的title中,Java出现的次数...原创 2019-08-28 20:55:53 · 236 阅读 · 0 评论 -
七 dis_max--best fields策略
1. 假设数据 doc1: title: black cat. content: The cat like eat fish. doc2: title: reddog. content: The dog like eat bone. doc3: title: yellow cat. content: yellow cat look good. doc4: title: wh...原创 2019-08-29 20:47:33 · 227 阅读 · 0 评论 -
八 tie_breaker参数优化dis_max
案例:搜索title或content中包含java beginner的帖子 GET /forum/article/_search { "query": { "dis_max": { "queries": [ { "match": { "title": "java beginner" }}, ...原创 2019-09-02 20:54:05 · 952 阅读 · 0 评论