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>
    }
    }
    }
    }
    }

  • 相关阅读:
    我总结的面试题系列:kafka
    RabbitMQ大厂面试题
    [Algorithm] 并查集
    [LintCode] 编辑距离
    [LeetCode] Length of Longest Fibonacci Subsequence
    [LintCode] 交叉字符串
    [LeetCode] Permutation Sequence
    Permutation Sequence
    [LeetCode] Next Permutation
    [LeetCode] Longest Palindromic Substring
  • 原文地址:https://www.cnblogs.com/runnerjack/p/8484497.html
Copyright © 2011-2022 走看看