es 学习 5 DSL mapping 使用 案例
来源:互联网 发布:js数组concat 编辑:程序博客网 时间:2024/06/05 10:22
<?php
别名修改_aliases{ "actions": [ { "remove": { "index": "index1", "alias": "index" } }, { "add": { "index": "index2", "alias": "index" } } ]}
{ "from": 0, "size": 20, "query": { "function_score": { "functions": [ { "gauss": { "created_at": { "origin": "2014/04/23 07:00:00",//何时开始 "scale": "2h",//控制 下降速度 缓慢,越大 下降越快"offset": "10h"//偏移量 } }, "weight": 10 } ],"query": { "match": { "description": "bmw" } },"score_mode": "multiply" } }}{ "query": { "function_score": { "filter": { "bool": { "should": { "multi_match": { "query": "宝马", "fields": [ "title", "advertiser_name", "advertiser_name_title" ] } } } }, "functions": [ { "filter": { "match": { "advertiser_name_title": "宝马" } }, "weight": "60" }, { "filter": { "match": { "title": "bmw" } }, "weight": "40" }, { "filter": { "match": { "advertiser_name": "宝马" } }, "weight": "60" }, { "script_score": { "script": "_score*doc['date3'].value" } }, { "gauss": { "date": { "origin": "20160829", "scale": "10d", "offset": "5d", "decay": 0.5 } } } ], "score_mode": "sum" } }}// analyzer : ik_max_word ik_smart ik // search_analyzer : ik_max_word ik_smart ik // 近义词 配置 index 案例{ "mappings":{ "addata_index":{ "_all": { "search_analyzer": "ik_syno_smart", "analyzer": "ik_syno" }, "properties": { "id": { "type": "float" }, "width": { "include_in_all": true, "type": "string" }, "metas": { "type": "string", "include_in_all": true, "search_analyzer": "ik_syno_smart", "analyzer": "ik_syno" } } } }}// ik 中文 分词 配置 案例{ "mappings": { "addata_index": { "_all": { "search_analyzer": "ik_smart", "analyzer": "ik_max_word" }, "properties": { "id": { "type": "float" }, "width": { "include_in_all": false, "type": "string" }, "tracker_full": { "type": "string", "include_in_all": true, "search_analyzer": "ik_smart", "analyzer": "ik_max_word" }, "subject_rand": { "type": "float", "include_in_all": false } } } }}// DSL 案例 使用 // function_score 使用
// {// "query": {// "function_score": {// "filter": {// "bool": {// "must": [// {// "multi_match": {// "query": "bmw",// "fields": [// "advertiser_name",// "title",// "advertiser_name_title"// ]// }// }// ]// }// },// "functions": [// {// "filter": {// "match": {// "advertiser_name": "bmw"// }// },// "weight": 100// },// {// "filter": {// "match": {// "title": "bmw"// }// },// "weight": 99// },// {// "script_score": {// "script": "_score + doc['created_date'].value"// }// }// ],// "score_mode": "sum"// }// }// } $curl_param = [ 'from'=>$from, 'size'=>$size, 'query'=>[ 'function_score'=>[ 'filter'=>[ 'bool'=>[ 'should'=>[ 'multi_match'=>[ 'query'=>$param, // 'type'=>'cross_fields', // 'operator'=>'and', 'fields'=>[ 'title', 'name' ] ] ] ] ], 'functions'=>[ [ 'filter'=>[ 'match'=>[ 'title'=>$param ] ], "weight"=>'10' ], [ 'filter'=>[ 'match'=>[ 'name'=>$param ] ], "weight"=>'10' ], [ 'script_score'=>[ 'script'=>"_score*doc['created_date'].value" // 'script'=>"_score*doc['date2'].value" ] ] ], // 'score_mode'=>'first' ] ] ];// multi_match 使用 $curl_param = [ 'from'=>$from, 'size'=>$size, 'query'=>[ 'multi_match'=>[ 'query'=>$param, 'type'=>'cross_fields', // 'type'=>'phrase', 'operator'=>'and', 'fields'=>[ 'name','title' //'name','title'//^4 ] ] ], // 'track_scores'=>true, // 'sort'=>[ // 'created_date'=>[ // 'order'=>'desc' // ] // ] "sort"=>[ [ '_script'=>[ 'script'=>"floor(doc['date2'].value)", 'type'=>'number', 'order'=>'desc' ] ], [ '_score'=>[ 'order'=>'desc' ] ] ] ];// aggs 统计 数据 $curl_param = [ 'query'=>[ 'bool'=>[ 'must'=>[ 'term'=>[ 'id'=>$id ] ] ] ], 'aggs'=>[ 'first_detected'=>[ 'min'=>[ 'field'=>'created_date' ] ], 'last_detected'=>[ 'max'=>[ 'field'=>'created_date' ] ] ] ];//多字段查询 $curl_param = [ 'sort'=>[ 'id'=>[ 'order'=>'desc' ] ], 'query'=>[ 'multi_match'=>[ 'query'=>$title, 'type'=>'best_fields', 'fields'=>[ 'title','domain','keywords' ], 'tie_breaker'=>0.3, 'minimum_should_match'=>'30%' ] ] ];// range 使用 $curl_param = [ 'sort'=>[ 'id'=>'desc' ], 'query'=>[ 'filtered'=>[ 'filter'=>[ 'range'=>[ 'id'=>[ 'gte'=>$min_id, 'lte'=>$max_id ] ] ] ] ] ];// group_by_state 使用 $curl_param = [ 'size'=>$size, 'query'=>[ 'bool'=>[ 'must'=>[ 'term'=>[ $field=>$value ] ], 'should'=>[ 'cname'=>$param ] ], ], 'aggs'=>[ 'group_by_state'=>[ 'terms'=>[ 'field'=>$groupBy ] ] ] ];// sort 使用 $curl_param = [ 'size'=>$size, 'sort'=>[ 'date'=>[ 'order'=>'desc' ] ], 'query'=>[ 'bool'=>[ 'must'=>[ 'term'=>[ $field=>$value ] ], 'should'=>[ 'cname'=>$param ] ], ], 'aggs'=>[ 'group_by_state'=>[ 'terms'=>[ 'field'=>$groupBy ] ] ] ];// sort 使用 多字段 // 只有满足第一个 条件时 才进行下一个条件排序 $curl_param = [ 'size'=>$size, 'sort'=>[ [ 'date'=>[ 'order'=>'desc' ] ], [ 'id'=>[ 'order'=>'desc' ] ] ], 'query'=>[ 'bool'=>[ 'must'=>[ 'term'=>[ $field=>$value ] ], 'should'=>[ 'cname'=>$param ] ], ], 'aggs'=>[ 'group_by_state'=>[ 'terms'=>[ 'field'=>$groupBy ] ] ] ];
0 0
- es 学习 5 DSL mapping 使用 案例
- es 学习 3 DSL 总结
- ES DSL
- ES学习笔记四-Query DSL
- ES 基本使用《四》--索引mapping
- ELK环境搭建及es使用sql to dsl 插件
- es 基本语法 使用 案例
- es 基本语法 使用 案例
- WebDSL:DSL设计案例
- ES参考之Query DSL
- Android中的OpenGL ES使用案例
- es中的mapping
- es修改mapping类型
- es 构造dsl性能优化点记录
- elasticsearch query DSL学习及使用——part1
- elasticsearch 学习博客系列<二> ES 中 index 设置 Mapping(表结构)
- DSL学习总结 -- 絮絮叨叨
- Knockout.js学习之mapping插件使用
- Mysql技术内幕索引部分
- MyWidget MyLabel-- 重写 -- 双击/单击/移动/事件
- ReentrantReadWriteLock类和ReentrantLock类的区别
- List集合sort
- wegwe3g23
- es 学习 5 DSL mapping 使用 案例
- 关于IPC的一点愚见
- AndroidStudio安装配置详细过程
- 设计模式之观察者模式
- TS流分析
- leetcode_c++:树:Count Complete Tree Nodes(222 )
- JDK安装与环境变量配置
- 11 第一个特效 12灯泡开关案列 13 找对象 14操作对象
- java 发送邮件