ES java生产相关api操作(SearchSourceBuilder)

这篇具有很好参考价值的文章主要介绍了ES java生产相关api操作(SearchSourceBuilder)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

private SearchSourceBuilder searchMallEsCondition(MallEsSearchFormDTO form) {
        BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        // 关键词查询[商品名称/货品名称/品牌名称]
//        if (StringUtils.isNotBlank(form.getKeywords())) {
//            List<String> analyzedWords = IkAnalzyerUtil.segmentPhraseByIk(form.getKeywords());
//            for (String word : analyzedWords) {
//                boolQuery.must(queryStringQuery(String.format("*%s*", word.trim())).field("goodsName").field("goodsInfoName"));
//            }
//        }
        if (StringUtils.isNotBlank(form.getKeywords())) {
            List<String> analyzedWords = IkAnalzyerUtil.segmentPhraseByIk(form.getKeywords());
            StringBuilder stringBuilder = new StringBuilder();
            analyzedWords.forEach(s -> {
                stringBuilder.append(s).append(" ");
            });
            boolQuery.must(QueryBuilders.multiMatchQuery(stringBuilder.deleteCharAt(stringBuilder.length() - 1).toString(), "goodsInfoName", "goodsName").operator(Operator.OR).minimumShouldMatch("2<70%"));
        }
        // 指定货品编码参数组合查询
//        List<String> goodsInfoItemNos = form.getGoodsInfoItemNos();
//        if (!ListHelper.isObjectNullOrEmpty(goodsInfoItemNos) && goodsInfoItemNos.size() > 0) {
//            BoolQueryBuilder includeBoolQuery = QueryBuilders.boolQuery();
//            for (String goodsInfoItemNo : goodsInfoItemNos) {
//                BoolQueryBuilder inBoolQuery = QueryBuilders.boolQuery();
//                inBoolQuery.must(matchQuery("goodsInfoItemNo", goodsInfoItemNo));
//                includeBoolQuery.should(inBoolQuery);
//            }
//            boolQuery.must(includeBoolQuery);
//        }
        //可销售渠道
        if (!ListHelper.isNullOrEmpty(form.getSaleChannels())) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("saleChannels.identityCode", form.getSaleChannels()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("saleChannels", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        //商品名称模糊查询
        if (StringUtils.isNotEmpty(form.getGoodsName())) {
            //boolQuery.must(queryStringQuery(String.format("*%s*", form.getGoodsName())).field("goodsName"));
            boolQuery.must(queryStringQuery(String.format("\"*%s*\" OR *%s*", form.getGoodsName(), form.getGoodsName())).field("goodsName"));
        }

        //货品名称模糊查询
        if (StringUtils.isNotEmpty(form.getGoodsInfoName())) {
            //boolQuery.must(queryStringQuery(String.format("*%s*", form.getGoodsInfoName())).field("goodsInfoName"));
            boolQuery.must(queryStringQuery(String.format("\"*%s*\" OR *%s*", form.getGoodsInfoName(), form.getGoodsInfoName())).field("goodsInfoName"));
        }

        if (!StringHelper.isNullOrEmpty(form.getPromotionFlag()) && "1".equals(form.getPromotionFlag())) {
            boolQuery.must(QueryBuilders.nestedQuery("marketingActivityList", QueryBuilders.existsQuery("marketingActivityList"), ScoreMode.None));
            searchSourceBuilder.sort("activityGoodsSort", SortOrder.ASC);
        }

        if (!StringHelper.isNullOrEmpty(form.getPromotionGrade())) {
            boolQuery.must(QueryBuilders.nestedQuery("marketingActivityList", QueryBuilders.queryStringQuery(String.format("*%s*", form.getPromotionGrade())).field("marketingActivityList.marketJoinGrade"), ScoreMode.None));
        }

        if (!StringHelper.isNullOrEmpty(form.getShowChannel())) {
            boolQuery.must(QueryBuilders.nestedQuery("marketingActivityList", QueryBuilders.queryStringQuery(String.format("*%s*", form.getShowChannel())).field("marketingActivityList.showChannel"), ScoreMode.None));
        }

        if (!StringHelper.isNullOrEmpty(form.getShowStock()) && "0".equals(form.getShowStock())) {

            RangeQueryBuilder goodsInfoStock = rangeQuery("goodsInfoStock")
                    .gt(0);
            boolQuery.must(goodsInfoStock);
        }

        /******查询是否上架商品********/
        if (StringUtil.isNotEmptyOrWhiteSpace(form.getGoodsInfoAdded())) {
            /****-1的时候表示全部****/
            if (!form.getGoodsInfoAdded().equals("-1")) {
                //默认查询是要在列表展示的
                if (form.getKeywords() != null) {
                    // 搜索是否上架的商品
                    boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", form.getGoodsInfoAdded()));
                } else {
                    if (form.isShowList()) {
                        // 搜索是否上架的商品
                        boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", form.getGoodsInfoAdded()))
                                // 是否列表显示
                                .must(QueryBuilders.termQuery("showList", "1"));
                    } else {
                        // 搜索是否上架的商品
                        boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", form.getGoodsInfoAdded()));
                    }
                }
            }
        } else {
            //默认查询是要在列表展示的
            if (form.getKeywords() != null) {
                boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", "1"));
            } else {
                if (form.isShowList()) {
                    // 搜索上架商品
                    boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", "1"))
                            // 是否列表显示
                            .must(QueryBuilders.termQuery("showList", "1"));
                } else {
                    // 搜索上架商品
                    boolQuery.must(QueryBuilders.termQuery("goodsInfoAdded", "1"));
                }
            }
        }

        //灰度上架:0=否;1=是
        if (!StringUtil.isNotEmptyOrWhiteSpace(form.getAlpha())) {
            //未设置,默认不看灰度上架货品
            boolQuery.must(QueryBuilders.termQuery("alpha", "0"));
        } else {
            if (form.getAlpha().equals("1")) {
                //能看灰度发布商品,不加条件筛选
            } else {
                boolQuery.must(QueryBuilders.termQuery("alpha", "0"));
            }
        }

        //Spu展示标记
        if (StringUtil.isNotEmptyOrWhiteSpace(form.getDisplaySpuFlag())) {
            boolQuery.must(QueryBuilders.termQuery("displaySpuFlag", form.getDisplaySpuFlag()));
        }

        //查询品牌id
        if (form.getBrandId() != null && form.getBrandId() > 0L) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("brand.brandId", form.getBrandId().toString()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("brand", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        //分类id
        if (null != form.getCatId() && form.getCatId() > 0L) {
            boolQuery.must(termQuery("catId", form.getCatId()));
        }

        // 指定商品ID查询
        if (null != form.getGoodsId() && form.getGoodsId() > 0L) {
            boolQuery.must(termQuery("goodsId", form.getGoodsId()));
        }
        // 多个商品ID查询
        if (!ListHelper.isNullOrEmpty(form.getGoodsIds())) {
            boolQuery.must(QueryBuilders.termsQuery("goodsId", form.getGoodsIds()));
        }
        // 指定货品ID查询
        if (null != form.getGoodsInfoId() && form.getGoodsInfoId() > 0L) {
            boolQuery.must(termQuery("goodsInfoId", form.getGoodsInfoId()));
        }
        // 多个货品ID查询
        if (!ListHelper.isNullOrEmpty(form.getGoodsInfoIds())) {
            boolQuery.must(QueryBuilders.termsQuery("goodsInfoId", form.getGoodsInfoIds()));
        }
        // 指定货品编码查询
        if (StringUtils.isNotEmpty(form.getGoodsInfoItemNo())) {
            boolQuery.must(matchQuery("goodsInfoItemNo", form.getGoodsInfoItemNo()));
        }

        // 多个货号询
        if (!ListHelper.isNullOrEmpty(form.getGoodsInfoItemNos())) {
            boolQuery.must(QueryBuilders.termsQuery("goodsInfoItemNo", form.getGoodsInfoItemNos()));
        }

        // 指定商品编码查询
        if (StringUtils.isNotEmpty(form.getGoodsNo())) {
            boolQuery.must(termQuery("goodsNo", form.getGoodsNo()));
        }

        // 多个商品编码
        if (!ListHelper.isNullOrEmpty(form.getGoodsNos())) {
            boolQuery.must(QueryBuilders.termsQuery("goodsNo", form.getGoodsNos()));
        }

        // 分类查询
        if (ArrayUtils.isNotEmpty(form.getCids()) && form.isVisitGcpt()) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("cateList.id", form.getCids()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("cateList", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        //剔除生产配套分类
        if (ArrayUtils.isNotEmpty(form.getCids()) && !form.isVisitGcpt()) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.mustNot(QueryBuilders.termsQuery("cateList.id", form.getCids()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("cateList", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }
        //至造云排除三级分类
        if (null != form.getExcludeFirstCateIds() && form.getExcludeFirstCateIds().size() > 0) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("cateList.id", form.getExcludeFirstCateIds().stream().map(x -> x + "").collect(Collectors.toList())));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("cateList", boolQueryBuilder, ScoreMode.None);
            boolQuery.mustNot(nestedQueryBuilder);
        }

        // 品牌查询
        if (ArrayUtils.isNotEmpty(form.getBrands())) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("brand.brandName", form.getBrands()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("brand", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        // 品牌查询
        if (ArrayUtils.isNotEmpty(form.getBrandIds())) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("brand.brandId", Arrays.asList(form.getBrandIds())));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("brand", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        if (!StringHelper.isNullOrEmpty(form.getBrandName())) {
            BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
            boolQueryBuilder.must(QueryBuilders.termsQuery("brand.brandName", form.getBrandName()));
            NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("brand", boolQueryBuilder, ScoreMode.None);
            boolQuery.must(nestedQueryBuilder);
        }

        // 扩展参数
        if (ArrayUtils.isNotEmpty(form.getParams())) {
            for (String param : form.getParams()) {
                String[] paramArr = param.split(":");
                if ("价格".equals(paramArr[0]) && paramArr.length > 1 && StringUtils.isNotEmpty(paramArr[1])) {
                    long[] prices = Arrays.stream(paramArr[1].split("-")).mapToLong(a -> {
                        try {
                            return Long.parseLong(a);
                        } catch (Exception e) {
                            log.error("商品根据价格查询出现异常", e);
                            return 0L;
                        }
                    }).toArray();
                    RangeQueryBuilder rangeQuery = QueryBuilders.rangeQuery("goodsInfoPreferPrice");
                    rangeQuery.gte(prices[0]);
                    rangeQuery.lte(prices.length > 1 ? prices[1] : 0);
                    boolQuery.filter(rangeQuery);
                } else {
                    BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
                    boolQueryBuilder.must(QueryBuilders.termQuery("paramList.attributeName", paramArr[0]));
                    boolQueryBuilder.must(QueryBuilders.termQuery("paramList.attributeValue", paramArr[1]));
                    NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("paramList", boolQueryBuilder, ScoreMode.None);
                    boolQuery.must(nestedQueryBuilder);
                }
            }
        }

        // 只显示有货
        if (Objects.nonNull(form.getShowStock()) && "0".equals(form.getShowStock())) {
//            searchRequest.addFilter(FilterBuilders.scriptFilter(filter_script)
//                    .addParam(CHECKWARE, Objects.isNull(form.getWareIds()) ? null : form.getWareIds()[0]));
        }


        if (form.getGroupGoodsId()) {
            CollapseBuilder collapseBuilder = new CollapseBuilder("goodsId");

            searchSourceBuilder.collapse(collapseBuilder);
        }


        // 排序
        if (StringUtils.isNotBlank(form.getSort())) {
            switch (form.getSort()) {
                // 价格升序
                case "11D":
//                    Script script = new Script(sort_script);
//                    ScriptSortBuilder scriptSortBuilder = SortBuilders.scriptSort(script, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.ASC);
//                    searchSourceBuilder.sort(scriptSortBuilder);
                    searchSourceBuilder.sort("goodsInfoMarketPrice", SortOrder.ASC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    break;
                // 价格降序
                case "1D":
                    searchSourceBuilder.sort("goodsInfoMarketPrice", SortOrder.DESC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    break;
                // 销量降序
                case "2D":

                    //默认过滤售罄的货品,三大专区,热销
                    BoolQueryBuilder includeBoolQuery = QueryBuilders.boolQuery();

                    //库存大于0
                    RangeQueryBuilder goodsInfoStock = rangeQuery("goodsInfoStock")
                            .gt(0);
                    //允许超卖
                    includeBoolQuery.should(QueryBuilders.termQuery("overSold", "1"));
                    includeBoolQuery.should(goodsInfoStock);

                    boolQuery.must(includeBoolQuery);
                    searchSourceBuilder.sort("mallSales", SortOrder.DESC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    searchSourceBuilder.sort("goodsInfoAddedTime", SortOrder.DESC);
                    break;
                // 销量升序
                case "22D":
                    searchSourceBuilder.sort("mallSales", SortOrder.ASC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    searchSourceBuilder.sort("goodsInfoAddedTime", SortOrder.ASC);
                    break;
                // 创建时间升序
                case "33D":
                    searchSourceBuilder.sort("createDate", SortOrder.ASC);


                    break;
                // 创建时间降序
                case "3D":
                    searchSourceBuilder.sort("createDate", SortOrder.DESC);
//                    searchRequest.addSort(new ScriptSortBuilder(date_sort_script, "number")
//                            .order(SortOrder.DESC));
//                    searchRequest.addSort(new ScriptSortBuilder(stock_sort_script, "number")
//                            .order(SortOrder.DESC));
                    break;
                // 收藏升序
                case "44D":
//                    searchRequest.addSort("collectionCount", SortOrder.ASC);
                    break;
                // 收藏降序
                case "4D":
//                    searchRequest.addSort("collectionCount", SortOrder.DESC);
                    break;
                // 上架时间升序
                case "55D":
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    searchSourceBuilder.sort("goodsInfoAddedTime", SortOrder.ASC);
                    break;
                // 上架时间降序
                case "5D":
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                    searchSourceBuilder.sort("goodsInfoAddedTime", SortOrder.DESC);
                    break;
                // 评论数升序
                case "66D":
//                    searchRequest.addSort("comment.commentCount", SortOrder.ASC);
                    break;
                // 评论数降序
                case "6D":
//                    searchRequest.addSort("comment.commentCount", SortOrder.DESC);
                    break;
                case "7D":
                    String marketJoinGrade = getMarketJoinGrade(form.getPriceGradeId());
                    //按照促销活动排序
                    if (!StringHelper.isNullOrEmpty(marketJoinGrade)) {
                        Map<String, Object> params = new HashMap<>();
                        params.put("zero", 0);
                        params.put("one", 1);
                        params.put("nullCode", null);
                        params.put("emptyStr", "");
                        params.put("marketJoinGrade", marketJoinGrade);
                        Script marketJoinGradeScript = new Script(ScriptType.INLINE, "painless", marketing_sort, params);
                        ScriptSortBuilder gradeScriptSortBuilder = SortBuilders.scriptSort(marketJoinGradeScript, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.DESC);
                        searchSourceBuilder.sort(gradeScriptSortBuilder);
                    } else {
                        Map<String, Object> params = new HashMap<>();
                        params.put("zero", 0);
                        params.put("one", 1);
                        params.put("marketJoinGrade", marketJoinGrade);
                        params.put("nullCode", null);
                        params.put("emptyStr", "");
                        Script marketJoinGradeScript = new Script(ScriptType.INLINE, "painless", no_login_marketing_sort, params);
                        ScriptSortBuilder gradeScriptSortBuilder = SortBuilders.scriptSort(marketJoinGradeScript, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.DESC);
                        searchSourceBuilder.sort(gradeScriptSortBuilder);
                    }
                    //按照商品名称带关键字货品
                    searchSourceBuilder.sort("weight", SortOrder.DESC);
                    //按照库存排序
                    Map<String, Object> stockParams = new HashMap<>();
                    stockParams.put("zero", 0);
                    stockParams.put("minusOne", -1);
                    stockParams.put("zeroStr", "0");
                    stockParams.put("oneStr", "1");
                    Script stockScript = new Script(ScriptType.INLINE, "painless", stock_sort, stockParams);
                    ScriptSortBuilder stockOrder = SortBuilders.scriptSort(stockScript, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.DESC);
                    searchSourceBuilder.sort(stockOrder);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
//                    searchSourceBuilder.sort("cat1Sort",SortOrder.ASC);
//                    searchSourceBuilder.sort("cat2Sort",SortOrder.ASC);
//                    searchSourceBuilder.sort("cat3Sort",SortOrder.ASC);
                    searchSourceBuilder.sort("goodsInfoAddedTime", SortOrder.DESC);
                    break;
                //根据价格升序
                case "88D": {
                /*    if (StringHelper.isNullOrEmpty(form.getPriceGradeId())){
                        break;
                    }
                    String sortField = getPriceLevel(form.getPriceGradeId());
                    Script script2 = new Script("def price=_source."+sortField+"; if(price<0){return 0;}else{return price;}");
                    ScriptSortBuilder scriptSortBuilder2 = SortBuilders.scriptSort(script2, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.ASC);
                    searchSourceBuilder.sort(scriptSortBuilder2);*/

                    searchSourceBuilder.sort("goodsInfoMarketPrice", SortOrder.ASC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                }
                break;
                //根据价格降序
                case "8D": {
         /*           if (StringHelper.isNullOrEmpty(form.getPriceGradeId())){
                        break;
                    }
                    String sortField = getPriceLevel(form.getPriceGradeId());
                    Script script3 = new Script("def price=_source."+sortField+"; if(price<0){return 0;}else{return price;}");
                    ScriptSortBuilder scriptSortBuilder3 = SortBuilders.scriptSort(script3, ScriptSortBuilder.ScriptSortType.NUMBER).order(SortOrder.DESC);
                    searchSourceBuilder.sort(scriptSortBuilder3);*/

                    searchSourceBuilder.sort("goodsInfoMarketPrice", SortOrder.DESC);
                    searchSourceBuilder.sort("_score", SortOrder.DESC);
                }
                break;
                default:
                    break;
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (form.getGoodsInfoAddedTimeSort() != null && form.getGoodsInfoAddedTimeSort() == 0) {
            boolQuery.must(termQuery("goodsInfoAdded", "1"));
            searchSourceBuilder.sort(sdf.format(form.getGoodsInfoAddedTime()), SortOrder.DESC);
        } else if (form.getGoodsInfoAddedTimeSort() != null && form.getGoodsInfoAddedTimeSort() == 1) {
            boolQuery.must(termQuery("goodsInfoAdded", "1"));
            searchSourceBuilder.sort(sdf.format(form.getGoodsInfoAddedTime()), SortOrder.ASC);
        }
        searchSourceBuilder.query(boolQuery);

        AggregationBuilder aggregation =
                AggregationBuilders.nested("paramList", "paramList")
                        .subAggregation(AggregationBuilders.terms("attributeName")
                                .field("paramList.attributeName").size(Integer.MAX_VALUE)
                                .subAggregation(AggregationBuilders.terms("attributeValue").field("paramList.attributeValue"))
                        );

        AggregationBuilder aggregation2 =
                AggregationBuilders.nested("brand", "brand")
                        .subAggregation(AggregationBuilders.terms("brandName").field("brand.brandName").size(Integer.MAX_VALUE)
                                .subAggregation(AggregationBuilders.terms("brandLogo").field("brand.brandLogo"))
                        );
        searchSourceBuilder.aggregation(aggregation);
        searchSourceBuilder.aggregation(aggregation2);
        searchSourceBuilder.from((form.getPageNo() - 1) * form.getPageSize()).size(form.getPageSize());

        return searchSourceBuilder;
    }

文章来源地址https://www.toymoban.com/news/detail-405001.html

到了这里,关于ES java生产相关api操作(SearchSourceBuilder)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 最新版ES8的client API操作 Elasticsearch Java API client 8.0

    作者:ChenZhen 本人不常看网站消息,有问题通过下面的方式联系: 邮箱:1583296383@qq.com vx: ChenZhen_7 我的个人博客地址:https://www.chenzhen.space/🌐 版权:本文为博主的原创文章,本文版权归作者所有,转载请附上原文出处链接及本声明。📝 如果对你有帮助,请给一个小小的s

    2024年02月04日
    浏览(41)
  • java使用elasticsearchClient调用es7.17-生成连接、查询系统参数、索引相关操作

    java调用elasticsearch有几种不同的方式,考虑到以后维护方便,使用elasticSearchClient进行数据交互 首先要进行maven引入,后面两个是与json转化有关的,刚开始测试可以无需引入 1、ModelTestCase 此实体整合了与es系统有关的相关参数 2、Person 此实体主要为测试索引中的数据结构 1、生

    2024年02月15日
    浏览(49)
  • Hadoop系统应用之HDFS相关操作 - - Java-API对HDFS的操作(IDEA版)

    通过Java API来操作HDFS文件系统HDFS,相关的操作有:文件上传、文件下载、新建文件夹、查看文件、删除文件。 1.Linux下安装好hadoop,这里使用hadoop2.7.3 2.window解压hadoop2.7.3的包 2.Windows下安装好jdk1.8  3.Windows下安装好IDEA,这里使用IDEA2022 4.Windows下安装好maven,这里使用Maven3.6.3

    2024年02月05日
    浏览(51)
  • 【Elasticsearch学习笔记五】es常用的JAVA API、es整合SpringBoot项目中使用、利用JAVA代码操作es、RestHighLevelClient客户端对象

    目录 一、Maven项目集成Easticsearch 1)客户端对象 2)索引操作 3)文档操作 4)高级查询 二、springboot项目集成Spring Data操作Elasticsearch 1)pom文件 2)yaml 3)数据实体类 4)配置类 5)Dao数据访问对象 6)索引操作 7)文档操作 8)文档搜索 三、springboot项目集成bboss操作elasticsearch

    2023年04月09日
    浏览(51)
  • Java SpringBoot API 实现ES(Elasticsearch)搜索引擎的一系列操作(超详细)(模拟数据库操作)

    小编使用的是elasticsearch-7.3.2 基础说明: 启动:进入elasticsearch-7.3.2/bin目录,双击elasticsearch.bat进行启动,当出现一下界面说明,启动成功。也可以访问http://localhost:9200/ 启动ES管理:进入elasticsearch-head-master文件夹,然后进入cmd命令界面,输入npm run start 即可启动。访问http

    2024年02月04日
    浏览(57)
  • 4、Elasticsearch7.6.1 Java api操作ES(CRUD、两种分页方式、高亮显示)和Elasticsearch SQL详细示例

    1、介绍lucene的功能以及建立索引、搜索单词、搜索词语和搜索句子四个示例实现 2、Elasticsearch7.6.1基本介绍、2种部署方式及验证、head插件安装、分词器安装及验证 3、Elasticsearch7.6.1信息搜索示例(索引操作、数据操作-添加、删除、导入等、数据搜索及分页) 4、Elasticsearch7

    2024年02月16日
    浏览(79)
  • kafka生产者api和数据操作

    发送流程 消息发送过程中涉及到两个线程—— main线程和Sender线程 main线程 使用serializer(并非java默认)序列化数据,使用partitioner确认发送分区 在main线程中创建了一个双端队列RecordAccumulator,main线程将批次数据发送给RecordAccumulator。 创建批次数据是从内存池中分配内存,在

    2024年02月13日
    浏览(35)
  • 3.es别名相关操作

    2024年02月15日
    浏览(41)
  • ES语法以及ajax相关操作

    ajax一个前后台配合的技术,它可以让javascript发送http请求,与后台通信,获取数据和信息。ajax技术的原理是实例化xmlhttp对象,使用此对象与后台通信。jquery将它封装成了一个函数$.ajax(),我们可以直接用这个函数来执行ajax请求。 ajax需要在服务器环境下运行。 $.ajax使用方法

    2024年02月08日
    浏览(35)
  • HDFS相关API操作

    HDFS API官方文档:https://hadoop.apache.org/docs/r3.3.1/api/index.html 将Hadoop的Jar包解压到非中文路径(例如D:hadoophadoop-2.7.2) 配置HADOOP_HOME环境变量 配置Path环境变量 准备工作 创建一个[Maven]工程HdfsClientDemo 引入hadoop-client依赖 创建HdfsClient 类 创建文件夹 上面这样写代码有点冗余,我们

    2024年02月02日
    浏览(69)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包