设为首页 加入收藏

TOP

使用 Java 注解自动化处理对应关系实现注释代码化(二)
2018-04-14 06:06:19 】 浏览:631
Tags:使用 Java 注解 自动化 处理 对应 关系 实现 注释 代码
t;String, Object> termFilter; private final Map<String, Range> rangeFilter; private final Map<String, Match> matchFilter; private int size; private String orderBy = null; private String order = null; // query 查询语法, 是否需要 filtered, filter 这两层 // 5.x 版本不再需要这两层 private boolean isNeedFilterLayer = true; private Integer from; private final Map<String, Object> mustNotTermFilter; private final Map<String,Object> shouldTermFilter; private Integer shouldMatchMinimum; private List<String> includes; private List<String> excludes; public EsQuery() { this.termFilter = new HashMap<>(); this.rangeFilter = new HashMap(); this.matchFilter = new HashMap(); this.mustNotTermFilter = new HashMap<>(); this.shouldTermFilter = new HashedMap(); this.size = DEFAULT_SIZE; this.includes = new ArrayList<>(); this.excludes = new ArrayList<>(); } public EsQuery addTermFilter(String key, Object value) { this.termFilter.put(key, value); return this; } public EsQuery addMustNotTermFilter(String key, Object value) { this.mustNotTermFilter.put(key, value); return this; } public EsQuery addAllMustNotTermFilter(Map<String,Object> mustNot) { if (mustNot != null && !mustNot.isEmpty()) { this.mustNotTermFilter.putAll(mustNot); } return this; } public EsQuery addShouldTermFilter(String key, Object value) { this.shouldTermFilter.put(key, value); return this; } public EsQuery addAllShouldTermFilter(Map<String,Object> should) { if (should != null && !should.isEmpty()) { this.shouldTermFilter.putAll(should); } return this; } public EsQuery addRangeFilter(String key, long gte, long lte){ this.rangeFilter.put(key, new Range(gte, lte)); return this; } public EsQuery addMatchFilter(String key, Match value) { this.matchFilter.put(key, value); return this; } public EsQuery addIncludeFields(List<String> includes) { this.includes.addAll(includes); return this; } public EsQuery addExcludeFields(List<String> excludes) { this.excludes.addAll(excludes); return this; } @Override public String toString() { return toJsonString(); } public String toJsonString() { Map<String, Object> finalQuery = new HashMap<>(); Map<String, Object> queryMap = new HashMap<>(); Map<String, Object> filteredMap = new HashMap<>(); Map<String, Object> filterMap = new HashMap<>(); Map<String, Object> boolMap = new HashMap<>(); List<Object> mustList = obtainTermFilterList(this.termFilter); List<Object> mustNotList = obtainTermFilterList(this.mustNotTermFilter); List<Object> shouldList = obtainTermFilterList(this.shouldTermFilter); if(!this.rangeFilter.isEmpty()){ for(Map.Entry<String, Range> e: this.rangeFilter.entrySet()){ Map<String, Object> rangeMap = new HashMap<>(); Map<String, Object> rangeEntityMap = new HashMap<>(); rangeEntityMap.put(e.getKey(), e.getValue().toMap()); rangeMap.put(Constant.range, rangeEntityMap); mustList.add(rangeMap); } } if(!this.matchFilter.isEmpty()){ this.matchF
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Java 虚拟机16:Metaspace 下一篇Spring 中获取 request 的几种方..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目