• ElasticSearch基本用法


    最大的特点:
    1. 数据库的 database, 就是  index
    2. 数据库的 table,  就是 tag
    3. 不要使用browser, 使用curl来进行客户端操作.  否则会出现 java heap ooxx...

    curl:  -X 后面跟 RESTful :  GET, POST ...
    -d 后面跟数据。 (d = data to send)

    1. create: 

    指定 ID 来建立新记录。 (貌似PUT, POST都可以)
    $ curl -XPOST localhost:9200/films/md/2 -d '
    { "name":"hei yi ren", "tag": "good"}'

    使用自动生成的 ID 建立新纪录:
    $ curl -XPOST localhost:9200/films/md -d '
    { "name":"ma da jia si jia3", "tag": "good"}'

    2. 查询:
    2.1 查询所有的 index, type:
    $ curl localhost:9200/_search?pretty=true

    2.2 查询某个index下所有的type:
    $ curl localhost:9200/films/_search

    2.3 查询某个index 下, 某个 type下所有的记录:
    $ curl localhost:9200/films/md/_search?pretty=true

    2.4 带有参数的查询: 

    $ curl localhost:9200/films/md/_search?q=tag:good
    {"took":7,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"film","_type":"md","_id":"2","_score":1.0, "_source" :
    { "name":"hei yi ren", "tag": "good"}},{"_index":"film","_type":"md","_id":"1","_score":0.30685282, "_source" :
    { "name":"ma da jia si jia", "tag": "good"}}]}}

    2.5 使用JSON参数的查询: (注意 query 和 term 关键字)
    $ curl localhost:9200/film/_search -d '
    {"query" : { "term": { "tag":"bad"}}}'

    3. update 
    $ curl -XPUT localhost:9200/films/md/1 -d { ...(data)... }

    4. 删除。 删除所有的:
    $ curl -XDELETE localhost:9200/films

    http://bbs.csdn.net/topics/300052325

  • 相关阅读:
    前端备战21秋招之操作系统,线程/进程/死锁
    前端备战秋招之计算机网络,这一篇足矣
    VS Code项目中共享自定义的代码片段方案
    eslint插件开发教程
    2020前端春招经验分享,从面试小白到老油条的蜕变
    使用nodejs从控制台读入内容
    js实现展开多级数组
    js使用typeof与instanceof相结合编写一个判断常见变量类型的函数
    07-数据结构
    06-流程控制
  • 原文地址:https://www.cnblogs.com/diyunpeng/p/3838636.html
Copyright © 2020-2023  润新知