GET/movie/_search
{"query":{"multi_match":{"query":"basketball with cartoom aliens","field":["title","overview"]// 在这两个字段同时查询}}}
再次解释评分规则(tf/idf)*tfnorm
tf:词频,这个document文档包含了多少个这个词,包含越多表明越相关
idf:逆文档频率,包含该词的文档总数目
tfnorm: 根据field长度做归一化,文档内出现频率越高,field越短越相关
// 操作不管是字符“与”还是“或”,按照逻辑关系命中后相加得分GET/movie/_search
{"explain":true,"query":{"match":{"title":"steve"}}}GET/movie/_search
{"query":{"multi_match":{"query":"basketball with cartoom aliens","fields":["title^10","overview"],// title乘了10的权重,着重标题查询"tie_break":0.3}}}
继续深入查询
Bool查询
must:必须都是true
must not:必须都是false
should:其中有一个为true即可,但true的越多得分越高
GET/movie/_search
{"query":{"bool":{"should":[{"match":{"title":"basketball with cartoom aliens"}},{"match":{"overview":"basketball with cartoom aliens"}}]}}}
不同的multi_query的type和multi_match得分不一样
因为multi_match有很多种type
默认是best_fields,取得分最高的作为对应的分数,最匹配模式,等同于dismax模式
GET/movie/_search
{"query":{"dis_max":{"queries":[{"match":{"title":"basketball with cartoom aliens"}},{"match":{"overview":"basketball with cartoom aliens"}}]}}}
GET/movie/_search
{"query":{"dis_max":{"queries":[{"match":{"title":"basketball with cartoom aliens"}},{"match":{"overview":"basketball with cartoom aliens"}}],"tie_breaker":0.3// 将其他因素以0.3的倍数考虑进去}}}