lucene DuplicateFilter 多segment去重问题

nj冰红茶 发布于 2017/09/28 14:23
阅读 211
收藏 0
GroupingSearch groupingSearch = new GroupingSearch("logTimeGroup");
//        groupingSearch.setGroupSort(new Sort(SortField.FIELD_SCORE));
//        groupingSearch.setFillSortFields(true);
//        groupingSearch.setCachingInMB(16.0, true);
        groupingSearch.setAllGroups(true);
//        groupingSearch.setAllGroupHeads(true);
        groupingSearch.setGroupDocsLimit(10);


        BooleanQuery booleanQuery = new BooleanQuery();
        TermRangeQuery rangeQuery = new TermRangeQuery("logTime",
                new Term("logTime", JodaTime.format(startDay, JodaTime.YYYY_MM_DD_HH_MM_SS)).bytes(),
                new Term("logTime", JodaTime.format(endDay, JodaTime.YYYY_MM_DD_HH_MM_SS)).bytes(), true, true);
        DuplicateFilter filter = new DuplicateFilter("logTimeUserIdFilter");//去重过滤
        filter.setKeepMode(DuplicateFilter.KeepMode.KM_USE_FIRST_OCCURRENCE);

        Query query = new TermQuery(new Term("appKey", appkey));
        booleanQuery.add(rangeQuery, BooleanClause.Occur.MUST);
        booleanQuery.add(query, BooleanClause.Occur.MUST);
        TopGroups<BytesRef> docs = null;
        if (type == 0) {
            docs = groupingSearch.search(searcher, booleanQuery, 0, 10);
        } else {
            docs = groupingSearch.search(searcher, filter, booleanQuery, 0, 10);
        }
加载中
0
nj冰红茶
nj冰红茶

怎么搞,,头疼死我了,需求卡了一周了

返回顶部
顶部