package com.walker.support.es.so; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 全文检索对象基类 * * @author 时克英 * @date 2017年3月22日 */ public abstract class BaseSearchObject { // 高亮数据对象 private Map> highlightMap; /** * 获取索引唯一编号 * * @return 索引唯一编号 */ public abstract String getId(); /** * 设置高亮字段内容 * * @param field 字段 * @param value 高亮摘要 */ synchronized public void putHighlight(String field, String value) { if (this.highlightMap == null) { this.highlightMap = new HashMap<>(); } if (!this.highlightMap.containsKey(field)) { this.highlightMap.put(field, new ArrayList()); } this.highlightMap.get(field).add(value); } /** * 获取高亮摘要 * * @param field 索引字段 * @return 高亮摘要 */ public List getHighlight(String field) { if (this.highlightMap == null) { return null; } else { return this.highlightMap.get(field); } } }