Elasticsearch查询所有索引列表curl -u elastic:pass1234 http://localhost:9200/_cat/indices?vpretty根据 id 查询文档curl -u elastic:pass1234 http://localhost:9200/索引名/_doc/id名?prettycurl -u elastic:pass1234 http://localhost:9200/imwl_wiki_documents_409/_doc/wiki_384?prettycurl -u elastic:pass1234 http://localhost:9200/test_person/_doc/aaa001?pretty创建索引 test_personcurl -u elastic:pass1234 -X PUT http://localhost:9200/test_person -H Content-Type: application/json -d { settings: { number_of_shards: 1, number_of_replicas: 1 }, mappings: { properties: { id: {type: keyword}, name: { type: text, fields: {keyword: {type: keyword,ignore_above: 256}} }, age: {type: integer}, hobbyList: {type: keyword} } } }索引 test_person 加新字段curl -u elastic:pass1234 -X PUT http://localhost:9200/test_person/_mapping -H Content-Type:application/json -d { properties: { gender: { type: keyword } } }查询索引 test_person 信息curl -u elastic:pass1234 http://localhost:9200/test_person/_mapping?pretty删除索引 test_personcurl -u elastic:pass1234 -X DELETE http://localhost:9200/test_person写入数据自定义idcurl -u elastic:pass1234 -X PUT http://localhost:9200/test_person/_doc/aaa001 -H Content-Type:application/json -d { id: aaa001, name: 张三, age: 28, hobbyList: [游泳,骑行,看书], gender: 男 }自动生成idcurl -u elastic:pass1234 -X POST http://localhost:9200/test_person/_doc -H Content-Type:application/json -d { name: 小红, age: 23, hobbyList: [画画,追剧], gender: 女 }查询数据查询 test_person 索引下所有数据curl -u elastic:pass1234 X POST http://localhost:9200/test_person/_search?pretty -H Content-Type:application/json -d { query: { match_all: {} }, size: 100 }精确匹配完整姓名等于小红term name.keywordcurl -u elastic:pass1234 -X POST http://localhost:9200/test_person/_search?pretty -H Content-Type:application/json -d { query: { term: { name.keyword: { value: 小红 } } } }模糊匹配包含 “红”、“小” 都能命中match 查询 text 字段 namecurl -u elastic:pass1234 -X POST http://localhost:9200/test_person/_search?pretty -H Content-Type:application/json -d { query: { match: { name: 小红 } } }精确匹配爱好 画画termhobbyList 是 keyword 数组curl -u elastic:pass1234 -X POST http://localhost:9200/test_person/_search?pretty -H Content-Type:application/json -d { query: { term: { hobbyList: { value: 画画 } } } }多爱好其中一个匹配terms同时查画画、篮球curl -u elastic:pass1234 -X POST http://http://localhost:9200/test_person/_search?pretty -H Content-Type:application/json -d { query: { terms: { hobbyList: [画画, 篮球] } } }