zoukankan      html  css  js  c++  java
  • elasticsearch基本Restful操作

    1、添加数据
    curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/megacorp/employee/3' -d'
    {
    "first_name" : "Jane",
    "last_name" : "Smith",
    "age" : 32,
    "about" : "I like to collect rock albums",
    "interests": [ "music" ]
    }';

    2、删除数据
    curl -XDELETE 'http://localhost:9200/megacorp/employee/1'

    3、查看记录
    curl -XGET 'http://localhost:9200/megacorp/employee/1'

    4、查看所有记录
    curl -XGET 'http://localhost:9200/megacorp/employee/_search'

    5、简单条件查询
    curl -XGET 'http://localhost:9200/megacorp/employee/_search?q=last_name:Smith'

    6、match 查询法
    curl -H "Content-Type: application/json" -XGET 'http://localhost:9200/megacorp/employee/_search' -d'
    {
    "query" : {
    "match" : {
    "about" : "rock climbing"
    }
    }
    }'

    7、短语搜索(匹配若干个单词或者短语)
    curl -H "Content-Type: application/json" -XGET 'http://localhost:9200/megacorp/employee/_search' -d'
    {
    "query" : {
    "match_phrase": {
    "about": "rock climbing"
    }
    }
    }'


    8、结构化搜索的限定条件 filter(过滤器)
    curl -XGET 'http://localhost:9200/megacorp/employee/_search' -d'
    {
    "query" : {
    "filtered" : {
    "filter" : {
    "range" : {
    "age" : { "gt" : 30 } <1>
    }
    },
    "query" : {
    "match" : {
    "last_name" : "Smith" <2>
    }
    }
    }
    }
    }

  • 相关阅读:
    作业17
    模块
    Find the Lost Sock (异或算法)
    CD(二分)
    数字流输入
    最大连续子序列(dp)
    STL学习----lower_bound和upper_bound算法
    输入挂(减少时间)
    暴力之全排列
    【C++】判断元素是否在vector中,对vector去重,两个vector求交集、并集
  • 原文地址:https://www.cnblogs.com/runnerjack/p/8484497.html
Copyright © 2011-2022 走看看