Elasticsearch 常用操作api

查询es各个状态

curl -XPUT http://192.168.1.28:9200/hd_news
curl -XPUT http://192.168.1.28:9200/hd_boxers
curl -XPUT http://192.168.1.28:9200/hd_videos
curl -XPUT http://192.168.1.28:9200/hd_community

增加数据

curl -XPUT http://192.168.1.28:9200/hd_news/fulltext/_mapping -d'{"properties": {"content": {"type": "text","analyzer":"ik_max_word","search_analyzer": "ik_max_word"}}}'
curl -XPUT http://192.168.1.28:9200/hd_boxers/fulltext/_mapping -d'{"properties": {"content": {"type": "text","analyzer":"ik_max_word","search_analyzer": "ik_max_word"}}}'
curl -XPUT http://192.168.1.28:9200/hd_videos/fulltext/_mapping -d'{"properties": {"content": {"type": "text","analyzer":"ik_max_word","search_analyzer": "ik_max_word"}}}'

curl -XPUT http://192.168.1.28:9200/hd_community/fulltext/_mapping -d'{"properties": {"content": {"type": "text","analyzer":"ik_max_word","search_analyzer": "ik_max_word"}}}'


curl -XPUT http://192.168.1.28:9200/hd_news/fulltext/1 -d'{"content":"旧上海的拳击人"}'

curl -XPUT http://192.168.1.28:9200/hd_news/fulltext/2 -d'{"content":"邹市明职业生涯"}'

curl -XPUT http://192.168.1.28:9200/hd_news/fulltext/3 -d'{"content":"月拳年刀一辈子枪"}'

curl -XPUT http://192.168.1.28:9200/hd_videos/fulltext/1 -d'{"content":"IBU杭州站视频回顾"}'

curl -XPUT http://192.168.1.28:9200/hd_videos/fulltext/2 -d'{"content":"跟美女学波比跳"}'

curl -XPUT http://192.168.1.28:9200/hd_videos/fulltext/3 -d'{"content":"帕奎奥精彩视频"}'

curl -XPUT http://192.168.1.28:9200/hd_boxers/fulltext/1 -d'{"content":"邹市明"}'

curl -XPUT http://192.168.1.28:9200/hd_boxers/fulltext/2 -d'{"content":"帕奎奥"}'

curl -XPUT http://192.168.1.28:9200/hd_boxers/fulltext/3 -d'{"content":"木村翔"}'

curl -XPUT http://192.168.1.28:9200/hd_community/fulltext/1 -d'{"content":"邹市明为什么败给了木村翔"}'

curl -XPUT http://192.168.1.28:9200/hd_community/fulltext/2 -d'{"content":"女生可以学拳吗"}'

curl -XPUT http://192.168.1.28:9200/hd_community/fulltext/3 -d'{"content":"IBU有拳王吗"}'

查询数据

XGET http://192.168.1.28:9200/hd_news/fulltext/1  查询单条

删除数据

XDELETE http://192.168.1.28:9200/hd_news/fulltext/1  删除单条

查询数据

curl -XPOST http://192.168.1.28:9200/hd_community/fulltext/_search  -d'{"query" : { "match" : { "content" : "邹市明" }},"highlight" : {"pre_tags" : ["<tag1>", "<tag2>"],        "post_tags" : ["</tag1>", "</tag2>"],"fields" : {"content" : {}}}}'

查询结果

{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_s
core":0.5446649,"hits":[{"_index":"hd_community","_type":"fulltext","_id":"1","_score":0.5446649,"_source":{"content":"邹市明为什么败给了木村翔"},"highlight":{"content":["<tag1>邹</tag1><tag1>市</tag1>明为什么败给了木村翔"]}}]}}

查询格式

{
    "query": {
        "match": {
            "content": "邹明"
        }
    }
}
发布了27 篇原创文章 · 获赞 3 · 访问量 1万+
展开阅读全文

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

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览