Elasticsearch---学习记录(4)

15.记录------查询体

使用GET进行查询,可以带入查询参数.

curl -XGET http://172.16.150.149:29200/facebook,twitter/_search?pretty -d '
{"from":5,"size":3}
'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
"total" : 4,
"successful" : 4,
"failed" : 0
  },
  "hits" : {
"total" : 8,
"max_score" : 1.0,
"hits" : [ {
  "_index" : "facebook",
  "_type" : "blog",
  "_id" : "AWZ668ZcHFL4sAFl7IMI",
  "_score" : 1.0,
  "_source" : {
"title" : "website",
"text" : "blog is making",
"date" : "2018/1016"
  }
}...

16.记录------匹配前缀解析查询

给定一个首字母,进行匹配.

-XGET http://172.16.150.149:29200/facebook,twitter/_search?pretty -d '
{"query":{
"match_phrase_prefix":{
"text":"blog i"
}}}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
"total" : 4,
"successful" : 4,
"failed" : 0
  },
  "hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [ {
  "_index" : "facebook",
  "_type" : "blog",
  "_id" : "AWZ67I_dHFL4sAFl7IMJ",
  "_score" : 1.0,
  "_source" : {
"title" : "website",
"text" : "blog is making",
"date" : "2018/1016"
  }
...

官方强烈推荐再设置match_phrase_prefix来设置后续匹配的个数.

 curl -XGET http://172.16.150.149:29200/facebook,twitter/_search?pretty -d '
{"query":{
"match_phrase_prefix":{
"text":"blog i"
}}}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
"total" : 4,
"successful" : 4,
"failed" : 0
  },
  "hits" : {
"total" : 3,
"max_score" : 1.0,
"hits" : [ {
  "_index" : "facebook",
  "_type" : "blog",
  "_id" : "AWZ67I_dHFL4sAFl7IMJ",
  "_score" : 1.0,
  "_source" : {
"title" : "website",
"text" : "blog is making",
"date" : "2018/1016"
  }
...

17.记录------多匹配查询与_score的进一步了解

curl -XGET http://172.16.150.149:29200/facebook,twitter/_search?pretty -d '
{"query":{
"multi_match":{
"query":"blog is ",
"fields":["title","text"]}}}'

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
"total" : 4,
"successful" : 4,
"failed" : 0
  },
  "hits" : {
"total" : 4,
"max_score" : 0.41762865,
"hits" : [ {
  "_index" : "facebook",
  "_type" : "blog",
  "_id" : "AWZ67I_dHFL4sAFl7IMJ",
  "_score" : 0.41762865,
  "_source" : {
"title" : "website",
"text" : "blog is making",
"date" : "2018/1016"
  }
...

_score字段的进一步了解

_score字段代表着被查询的文章与查询的相关性程度,分越高,自然相关度就越高.

查询结果,往往都按照_score进行降序显示.

es的评分机制,是建立于lucene的评分基础之上,并且不限于其评分机制.

lucene评分机制

TF/IDF(词频/逆文档频率)算法

其计算文档得分需要考虑若干的影响因素

文档权重(document boost)
字段权重(field boost)
协调因子(coord)
逆文档频率(inverse document frequency)
长度范数(length norm)
词频
查询函数(query norm)

参考详见还包括了Lucene默认与实际评分公式

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值