摘要: 一、term query 精确查询 不分词 二、terms query 相当于 IN 查询 三、range query 范围查询 四、exists query 类似于SQL语句中的IS_NULL exists 和 missing 过滤可以用于查找文档中是否包含指定字段或没有某个字段,类似于SQL语句 阅读全文
posted @ 2017-12-26 18:56 小蚕豆 阅读(907) 评论(0) 推荐(0) 编辑
摘要: 上面的查询匹配就会进行分词,比如"宝马多少马力"会被分词为"宝马 多少 马力", 所有有关"宝马 多少 马力", 那么所有包含这三个词中的一个或多个的文档就会被搜索出来。并且根据lucene的评分机制(TF/IDF)来进行评分。 { "query_string":{ "default_field": 阅读全文
posted @ 2017-12-26 18:53 小蚕豆 阅读(656) 评论(0) 推荐(0) 编辑
摘要: GET /index/type/_search { "size" : 0, "aggs": { "agg_sex": { "terms": { "field": "sex" }, "agg_age": { "avg_age": { "avg": { "field": "age&q 阅读全文
posted @ 2017-12-26 17:57 小蚕豆 阅读(1547) 评论(0) 推荐(0) 编辑
摘要: 一、根据索引、类型、ID 获取多文档 MultiGetResponse multiGetItemResponses = client.prepareMultiGet() .add("twitter", "tweet", "1") .add("twitter", "tweet", "2", "3", 阅读全文
posted @ 2017-12-26 16:58 小蚕豆 阅读(757) 评论(0) 推荐(0) 编辑
摘要: import static org.elasticsearch.common.xcontent.XContentFactory.*; BulkRequestBuilder bulkRequest = client.prepareBulk(); // either use client#prepare 阅读全文
posted @ 2017-12-26 16:58 小蚕豆 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 一、修改部分字段By UpdateRequest client.prepareUpdate("ttl", "doc", "1") .setScript(new Script("ctx._source.gender = \"male\"" , ScriptService.ScriptType.INLI 阅读全文
posted @ 2017-12-26 16:24 小蚕豆 阅读(15714) 评论(0) 推荐(0) 编辑
摘要: BulkByScrollResponse response = DeleteByQueryAction.INSTANCE.newRequestBuilder(client) // transport client .filter(QueryBuilders.matchQuery("gender", 阅读全文
posted @ 2017-12-26 16:14 小蚕豆 阅读(1885) 评论(0) 推荐(0) 编辑
摘要: 一、创建索引 /**** * Setting 相关设置 */ static final Builder builder = Settings.builder().put("index.analysis.search_analyzer.default.type", "ik_smart") .put(" 阅读全文
posted @ 2017-12-26 15:48 小蚕豆 阅读(558) 评论(0) 推荐(0) 编辑
摘要: ElasticSearch 允许将一个JSON字符串作为文档。 生成JSON文档有下面几种方式: Manually (aka do it yourself) using native byte[] or as a String(自己构造byte[] 或者json串) Using a Map that 阅读全文
posted @ 2017-12-26 12:58 小蚕豆 阅读(647) 评论(0) 推荐(0) 编辑
摘要: /** * 初始化EsClient * * @param esClusterDomain * @param esClusterName */ private static void initClient(String esClusterDomain, String esClusterName) { 阅读全文
posted @ 2017-12-26 12:45 小蚕豆 阅读(540) 评论(0) 推荐(0) 编辑