关闭

es guass 案例

101人阅读 评论(0) 收藏 举报
分类:
_analyze?analyzer=standard



curl -XPOST http://192.168.1.47:9200/searchtube

"search_analyzer": "ik_max_word",
"analyzer": "ik_max_word"

curl -XPUT http://192.168.1.47:9200/searchtube/video/_mapping -d '{
  "video": {
    "properties": {
      "title": {
        "type": "string",
        "search_analyzer": "ik_max_word",
        "analyzer": "ik_max_word"
      },
      "description": {
        "type": "string",
        "search_analyzer": "ik_max_word",
        "analyzer": "ik_max_word"
      },
      "views": {
        "type": "integer"
      },
      "likes": {
        "type": "integer"
      },
      "created_at": {
        "type": "date",
        "format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
      }
    }
  }
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/1 -d '{
  title: "pg.com",
  description: "pg.com",
  views: 500,
  likes:2,
  created_at: "2014/04/22 04:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/2 -d '{
  title: "欧莱雅",
  description: "欧莱雅品牌",
  views: 6000,
  likes: 100,
  created_at: "2014/04/22 05:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/3 -d '{
  title: "bmw",
  description: "bmw",
  views: 100,
  likes: 130,
  created_at: "2014/04/22 06:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/8 -d '{
  title: "宝马",
  description: "bmw",
  views: 100,
  likes: 130,
  created_at: "2014/04/22 07:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/9 -d '{
  title: "宝马 x6",
  description: "bwm.com",
  views: 900,
  likes: 730,
  created_at: "2014/04/22 08:00:00"
}'
curl -XPUT http://192.168.1.47:9200/searchtube/video/10 -d '{
  title: "宝马 x10",
  description: "bwm.com bmw",
  views: 90,
  likes: 630,
  created_at: "2014/04/22 09:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/11 -d '{
  title: "宝马 x11",
  description: "bwm.com bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/22 10:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/4 -d '{
  title: "baidu",
  description: "baidu.com",
  views: 100,
  likes:2,
  created_at: "2014/04/22 09:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/5 -d '{
  title: "宝洁",
  description: "pg.com",
  views: 300,
  likes:2,
  created_at: "2014/04/22 10:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/6 -d '{
  title: "宝洁 广告",
  description: "pg.taobao.com",
  views: 300,
  likes:2,
  created_at: "2014/04/22 11:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/7 -d '{
  title: "天猫",
  description: "taoobao.com",
  views: 800,
  likes:2,
  created_at: "2014/04/22 13:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/12 -d '{
  title: "宝马 x12",
  description: "bwm.com bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/23 10:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/13 -d '{
  title: "宝马 x13",
  description: "bwm",
  views: 200,
  likes: 530,
  created_at: "2014/04/24 10:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/14 -d '{
  title: "bmw",
  description: "bwm",
  views: 200,
  likes: 530,
  created_at: "2014/04/24 11:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/15 -d '{
  title: "bmw",
  description: "bwm",
  views: 200,
  likes: 530,
  created_at: "2014/04/24 12:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/16 -d '{
  title: "bmw 24",
  description: "bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/24 13:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/17 -d '{
  title: "bmw 25",
  description: "bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/24 14:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/18 -d '{
  title: "bmw 25",
  description: "bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/25 14:00:00"
}'

curl -XPUT http://192.168.1.47:9200/searchtube/video/19 -d '{
  title: "bmw 25",
  description: "bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/26 14:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/20 -d '{
  title: "宝马 x12",
  description: "bwm.com bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/23 11:00:00"
}'


curl -XPUT http://192.168.1.47:9200/searchtube/video/21 -d '{
  title: "宝马 x12",
  description: "bwm.com bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/23 12:00:00"
}'



curl -XPUT http://192.168.1.47:9200/searchtube/video/22 -d '{
  title: "宝马 x12",
  description: "bwm.com bmw",
  views: 200,
  likes: 530,
  created_at: "2014/04/23 13:00:00"
}'


curl -XPOST http://192.168.1.47:9200/searchtube/_search -d '
{
  "query": {
    "function_score": {
      "query": {"match": {"_all": "severed"}},
      "script_score": {
        "script": "_score * log(doc['likes'].value + doc['views'].value + 1)"
      }
    }
  }
}'



curl -XPOST http://192.168.1.47:9200/searchtube/_search -d '
{
  "query": {
    "function_score": {
      "query": {"match": {"_all": "severed"}},
      "script_score": {
        "script": "_score * doc['views'].value + 1"
      }
    }
  }
}'



{
  "query": {
    "function_score": {
        "functions": [
          {
            "gauss": {
                "created_at": {
                    "origin": "2014-04-22T23:50:00",
                    "scale": "12h",
                    "offset": "1h",
                    "decay": 0.3
                }
            }
          },
          {
            "gauss": {
              "likes": {
                  "origin": 20000,
                  "scale": 20000
              }
            }
          },
          {
            "gauss": {
              "views": {
                  "origin": 20000,
                  "scale": 20000
              }
            }
          }
        ]
    }
  }
}



curl -XGET 'localhost:9200/hotels/_search/?pretty' -d'
{
  "query": {
    "function_score": {
      "functions": [
        {
          "gauss": {
            "price": {
              "origin": "0",
              "scale": "20"
            }
          }
        },
        {
          "gauss": {
            "location": {
              "origin": "11, 12",
              "scale": "2km"
            }
          }
        }
      ],
      "query": {
        "match": {
          "properties": "balcony"
        }
      },
      "score_mode": "multiply"
    }
  }
}'

0
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:32376次
    • 积分:1352
    • 等级:
    • 排名:千里之外
    • 原创:101篇
    • 转载:39篇
    • 译文:1篇
    • 评论:0条
    文章分类