删除索引 curl -XDELETE 192.168.1.95:9200/*2020.06*,*2020.07*,*2020.08* { "query": { "bool": { "must": { "match": { "spaceStr.raw": { "query": "家居住宅", "type": "phrase" } } } } } } ES学习 这个是 测试环境的 host : 192.168.1.36:9200 index : search_test_v171120 type : xiaoguotu host : 192.168.1.152:9200 index : search_v20160420 type : xiaoguotu http://192.168.1.36:9200/_plugin/kopf/ #弃用 http://192.168.2.57:9200/_plugin/kopf/ http://192.168.1.152:9200/_plugin/kopf/#/!/cluster 1.相关概念 http://wiki.we.com:8090/pages/viewpage.action?pageId=38502846 index 数据库 type 表 2.restful接口来操作 http://192.168.2.57:9200/_plugin/kopf/ http://192.168.2.57:9200/ipic_test20180402/categories/_search { "query": { "term": { "uid": "6282" } }, "sort": { "_script": { "script": "doc['hits'].value - 4 * doc['puttime'].value", "type": "number", "order": "desc" } } } show mappings 查看字段 先curl通了再改Java代码 开调试模式,看 querybuilder里的值符不符合语法 3.开发环境没数据,上测试就可以了 4.如何新增表 5.运行elasticsearch 打开命令行,进入D:\soft\elasticsearch-6.5.3\bin 运行 elasticsearch 6.新增index 7.term { "query": { "term": { "proj": { "value": "t8t-mid-wom", "boost": 1.0 } } } } 8.多个字段 { "query": { "constant_score": { "filter": { "bool": { "must": [ { "term": { "added_by": "1000" } }, { "term": { "ca_ispass": 1 } } ] } } } } } 9.多个值terms { "query": { "constant_score": { "filter": { "terms": { "added_by": [ 1000, 6282 ] } } } } } 10.范围 { "query": { "range": { "case_num": { "gte": 1, "lte": 20 } } } } 11.排序 { "from":0, "sort": [ { "feed_scores": { "order": "desc", "unmapped_type": "long" } } ], "size":1000 } 12.更新 https://www.elastic.co/guide/en/elasticsearch/reference/5.0/_updating_documents.html 13.获取mappings http://test.es.search.com:9200/shejiben_ipic_dev/_mapping?pretty 14.should里面嵌套must,要用bool { "query": { "bool": { "must": [ { "term": { "city": "深圳" } }, { "range": { "user_score": { "from": 1, "to": null, "include_lower": true, "include_upper": false } } } ], "should": [ { "terms": { "goodlevel": [ 2, 4, 5 ] } }, { "bool": { "must": [ { "term": { "apply_status": 4 } }, { "range": { "case_num": { "from": 1, "to": null, "include_lower": true, "include_upper": false } } } ] } } ] } } } 15.