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": "邹明"
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值