ElasticSearch索引基本查询语法[通俗易懂]

2022-11-01 14:18:45 浏览数 (3)

大家好,又见面了,我是你们的朋友全栈君。

#列出所有索引

GET http://127.0.0.1:9200/_cat/indices?v

#删除索引

DELETE 索引名

# 条件查询

GET http://127.0.0.1:9200/索引/_search?pretty

{ “query”: { “bool”: { “must”: [ { “match”: {

“tweet”: “elasticsearch”

} }, { “match”: { “name”: “zhangsan” } } ] } }

}

# 复合查询

GET http://127.0.0.1:9200/索引/_search?pretty { “bool”: { “must”: { “match”: { “tweet”: “elasticsearch” }, “match”: { “tweet”: “elasticsearch” } }, “must_not”: { “match”: { “name”: “mary” }}, “should”: { “match”: { “tweet”: “full text” }}, “filter”: { “range”: { “age” : { “gt” : 30 }} } } }

创建索引

PUT /es_index { “settings”: { “analysis”: { “normalizer”: { “my_normalizer”: { “type”: “custom”, “char_filter”: [], “filter”: [ “lowercase”, “asciifolding” ] } } } }, “mappings”: { “myindex”: { “properties”: { “Id”: { “type”: “keyword” }, “code”: { “type”: “keyword”, “normalizer”: “my_normalizer” }, “name”: { “type”: “text”, “analyzer”: “ik_max_word”, “search_analyzer”: “ik_max_word”, “fielddata”:true, “fields”: {“keyword”: {“type”: “keyword”}} }, “type”: { “type”: “keyword” }, “formId”: { “type”: “keyword” }, “lastEntryESDate”: { “type”: “date”, “format”: “yyyy-MM-dd HH:mm:ss” } } } }

}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/203964.html原文链接:https://javaforall.cn

0 人点赞