shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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<String, List<String>> 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<String>());
        }
        this.highlightMap.get(field).add(value);
    }
 
    /**
     * 获取高亮摘要
     *
     * @param field 索引字段
     * @return 高亮摘要
     */
    public List<String> getHighlight(String field) {
        if (this.highlightMap == null) {
            return null;
        } else {
            return this.highlightMap.get(field);
        }
    }
}