fyj的博客

菜鸟的天空

es guass 案例

_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"
    }
  }
}'

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014017121/article/details/52385560
个人分类: elasticsearch 代码片
上一篇es 学习 5 DSL mapping 使用 案例
下一篇editplus 使用 替换 查找
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭