#索引一个文档,-XPUT手动创建索引,curl -XPUT 'localhost:9200/get-together/_doc/1?pretty' -H 'Content-Type: application/json' -d '{"name": "Elasticsearch Denver","organizer": "Lee"}'#返回结果{"_index" : "get-together","_id" : "1","_version" : 2,"result" : "updated","_shards" : {"total" : 2,"successful" : 1,"failed" : 0},"_seq_no" : 1,"_primary_term" : 1}#kibana 请求GET /get-together/_search#响应:{"took": 277,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 1,"relation": "eq"},"max_score": 1,"hits": [{"_index": "get-together","_id": "1","_score": 1,"_source": {"name": "Elasticsearch Denver","organizer": "Lee"}}]}}#在kibana 中获取索引的映射_mappingGET /get-together/_mapping#响应:{"get-together": {"mappings": {"properties": {"name": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"organizer": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}}}}}}
#通过curl获取一个索引的映射_mapping
#查询出至少含有两个关键词的文档GET /get-together/_search{"query": {"bool": {"should": [{ "term": { "tags": "jvm" } },{ "term": { "tags": "hadoop" } },{ "term": { "tags": "java" } }],"minimum_should_match": 2}},"_source": ["name", "tags"]}
#搜索同时包含Elasticsearch 和 Denver关键词的文档GET /get-together/_search{"query": {"match": {"name": {"query": "Elasticsearch Denver","operator": "and"}}}}
#词组查询 match_phraseGET /get-together/_search{"query": {"match_phrase": {"name": { "query": "enterprise london","slop": 1}}},"_source": ["name","description"]}
#搜索词匹配前缀返回高亮提示GET /get-together/_search{"query": {"match_phrase_prefix": {"description": {"query": "Elasticsearch bas","max_expansions": 2}}},"_source": ["name","description"]}
#同时在多个字段中搜索某个字符串multi_matchGET /get-together/_search{"query": {"multi_match": {"query": "elasticsearch hadoop","fields": ["name","description"]}}}