Showing
17 changed files
with
520 additions
and
12 deletions
1 | +package com.yohomars.search.index.appender.impls; | ||
2 | + | ||
3 | +import com.yohomars.search.index.appender.IndexAppender; | ||
4 | +import org.springframework.stereotype.Component; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +/** | ||
9 | + * @author gris.wang | ||
10 | + * @since 2018/3/8 | ||
11 | + **/ | ||
12 | +@Component | ||
13 | +public class ContentIndexAppender implements IndexAppender { | ||
14 | + | ||
15 | + @Override | ||
16 | + public Integer getMinId() throws Exception { | ||
17 | + return null; | ||
18 | + } | ||
19 | + | ||
20 | + @Override | ||
21 | + public Integer getMaxId() throws Exception { | ||
22 | + return null; | ||
23 | + } | ||
24 | + | ||
25 | + @Override | ||
26 | + public List<?> getListByLimit(int min, int limit) throws Exception { | ||
27 | + return null; | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public String getId(Object object) { | ||
32 | + return null; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public String getRealId(Object object) { | ||
37 | + return null; | ||
38 | + } | ||
39 | +} |
@@ -14,6 +14,7 @@ public interface IndexBuilder { | @@ -14,6 +14,7 @@ public interface IndexBuilder { | ||
14 | * @return 总数 | 14 | * @return 总数 |
15 | * @throws Exception 异常 | 15 | * @throws Exception 异常 |
16 | */ | 16 | */ |
17 | + @Deprecated | ||
17 | int getTotalCount() throws Exception; | 18 | int getTotalCount() throws Exception; |
18 | 19 | ||
19 | /** | 20 | /** |
@@ -23,6 +24,7 @@ public interface IndexBuilder { | @@ -23,6 +24,7 @@ public interface IndexBuilder { | ||
23 | * @return 数据列表 | 24 | * @return 数据列表 |
24 | * @throws Exception 异常 | 25 | * @throws Exception 异常 |
25 | */ | 26 | */ |
27 | + @Deprecated | ||
26 | List<?> getPageLists(int offset, int limit) throws Exception; | 28 | List<?> getPageLists(int offset, int limit) throws Exception; |
27 | 29 | ||
28 | /** | 30 | /** |
1 | +package com.yohomars.search.index.builder.impls; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.alibaba.fastjson.JSONObject; | ||
5 | +import com.yoho.search.dal.ContentMapper; | ||
6 | +import com.yoho.search.dal.model.Content; | ||
7 | +import com.yoho.search.dal.model.ContentTag; | ||
8 | +import com.yohomars.search.index.builder.IndexBuilder; | ||
9 | +import org.apache.commons.collections.CollectionUtils; | ||
10 | +import org.apache.commons.lang.StringUtils; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.stereotype.Component; | ||
13 | + | ||
14 | +import java.util.ArrayList; | ||
15 | +import java.util.LinkedHashMap; | ||
16 | +import java.util.List; | ||
17 | +import java.util.Map; | ||
18 | + | ||
19 | +/** | ||
20 | + * @author gris.wang | ||
21 | + * @since 2018/3/8 | ||
22 | + **/ | ||
23 | +@Component | ||
24 | +public class ContentIndexBuilder implements IndexBuilder{ | ||
25 | + | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private ContentMapper contentMapper; | ||
29 | + | ||
30 | + @Override | ||
31 | + public int getTotalCount() throws Exception { | ||
32 | + return 0; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public List<?> getPageLists(int offset, int limit) throws Exception { | ||
37 | + return null; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public Integer getMinId() throws Exception { | ||
42 | + return contentMapper.selectMinId(); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public Integer getMaxId() throws Exception { | ||
47 | + return contentMapper.selectMaxId(); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public List<?> getListByRange(int min, int max) throws Exception { | ||
52 | + List<Content> list = contentMapper.selectListByRange(min,max); | ||
53 | + List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | ||
54 | + if(CollectionUtils.isNotEmpty(list)) { | ||
55 | + List<Integer> contentIds = new ArrayList<>(list.size()); | ||
56 | + for (Content content : list) { | ||
57 | + String title = content.getTitle(); | ||
58 | + String cover = content.getCover(); | ||
59 | + String summary = content.getSummary(); | ||
60 | + try { | ||
61 | + if(StringUtils.isNotBlank(title) && title.startsWith("{")) { | ||
62 | + JSONObject obj = JSON.parseObject(title); | ||
63 | + title = obj.getString("s"); | ||
64 | + } | ||
65 | + if(StringUtils.isNotBlank(cover) && cover.startsWith("{")) { | ||
66 | + JSONObject obj = JSON.parseObject(cover); | ||
67 | + cover = obj.getString("pic"); | ||
68 | + } | ||
69 | + if(StringUtils.isNotBlank(summary) && summary.startsWith("{")) { | ||
70 | + JSONObject obj = JSON.parseObject(summary); | ||
71 | + summary = obj.getString("s"); | ||
72 | + } | ||
73 | + }catch (Exception e){ | ||
74 | + // ignore | ||
75 | + } | ||
76 | + content.setTitle(title); | ||
77 | + content.setCover(cover); | ||
78 | + content.setSummary(summary); | ||
79 | + contentIds.add(content.getCid()); | ||
80 | + } | ||
81 | + if(CollectionUtils.isNotEmpty(contentIds)) { | ||
82 | + List<ContentTag> contentTags = contentMapper.selectTagsByIds(contentIds); | ||
83 | + if(CollectionUtils.isNotEmpty(contentTags)) { | ||
84 | + for (Content content : list) { | ||
85 | + for (ContentTag tag : contentTags) { | ||
86 | + if(tag.getCid().equals(content.getId())){ | ||
87 | + content.addTagId(tag.getTagId()); | ||
88 | + content.addTagName(tag.getTagName()); | ||
89 | + content.increaseTagCount(1); | ||
90 | + } | ||
91 | + } | ||
92 | + } | ||
93 | + } | ||
94 | + } | ||
95 | + for (Content content : list) { | ||
96 | + dataList.add(beanToMap(content)); | ||
97 | + } | ||
98 | + } | ||
99 | + return dataList; | ||
100 | + } | ||
101 | + | ||
102 | + @Override | ||
103 | + public String getId(Object object) { | ||
104 | + return ((Map)object).get("id").toString(); | ||
105 | + } | ||
106 | + | ||
107 | + /** | ||
108 | + * 拼装对象数据为map | ||
109 | + * @param content | ||
110 | + * @return | ||
111 | + */ | ||
112 | + private Map<String, Object> beanToMap(Content content) { | ||
113 | + Map<String, Object> map = new LinkedHashMap<>(); | ||
114 | + map.put("id", content.getId()); | ||
115 | + map.put("cid", content.getCid()); | ||
116 | + map.put("type", content.getType()); | ||
117 | + map.put("app", content.getApp()); | ||
118 | + map.put("title",content.getTitle()); | ||
119 | + map.put("cover",content.getCover()); | ||
120 | + map.put("summary",content.getSummary()); | ||
121 | + map.put("relate_account",content.getRelateAccount()); | ||
122 | + map.put("tag_ids",content.getTagIds()); | ||
123 | + map.put("tag_names",content.getTagNames()); | ||
124 | + map.put("tag_count",content.getTagCount()); | ||
125 | + return map; | ||
126 | + } | ||
127 | + | ||
128 | + | ||
129 | +} |
@@ -5,6 +5,7 @@ import com.yoho.search.dal.StoreMapper; | @@ -5,6 +5,7 @@ import com.yoho.search.dal.StoreMapper; | ||
5 | import com.yoho.search.dal.model.Store; | 5 | import com.yoho.search.dal.model.Store; |
6 | import com.yohomars.search.index.builder.IndexBuilder; | 6 | import com.yohomars.search.index.builder.IndexBuilder; |
7 | 7 | ||
8 | +import org.apache.commons.collections.CollectionUtils; | ||
8 | import org.apache.commons.lang3.StringUtils; | 9 | import org.apache.commons.lang3.StringUtils; |
9 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
10 | import org.slf4j.LoggerFactory; | 11 | import org.slf4j.LoggerFactory; |
@@ -58,9 +59,9 @@ public class StoreIndexBuilder implements IndexBuilder { | @@ -58,9 +59,9 @@ public class StoreIndexBuilder implements IndexBuilder { | ||
58 | public List<?> getListByRange(int min, int max) throws Exception { | 59 | public List<?> getListByRange(int min, int max) throws Exception { |
59 | List<Store> list = storeMapper.selectListByRange(min, max); | 60 | List<Store> list = storeMapper.selectListByRange(min, max); |
60 | List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); | 61 | List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); |
61 | - if (list != null && list.size() > 0) { | ||
62 | - for (int i = 0; i < list.size(); i++) { | ||
63 | - dataList.add(beanToMap(list.get(i))); | 62 | + if(CollectionUtils.isNotEmpty(list)) { |
63 | + for (Store store : list) { | ||
64 | + dataList.add(beanToMap(store)); | ||
64 | } | 65 | } |
65 | } | 66 | } |
66 | return dataList; | 67 | return dataList; |
@@ -32,7 +32,7 @@ public class RunnableQueueFactory { | @@ -32,7 +32,7 @@ public class RunnableQueueFactory { | ||
32 | public void addTask(String type, Runnable task){ | 32 | public void addTask(String type, Runnable task){ |
33 | BlockingQueue<Runnable> queue = queueMap.get(type); | 33 | BlockingQueue<Runnable> queue = queueMap.get(type); |
34 | if(queue==null){ | 34 | if(queue==null){ |
35 | - queue = new ArrayBlockingQueue<>(MAX_QUEUE_CAPACITY); | 35 | + queue = new LinkedBlockingQueue<>(MAX_QUEUE_CAPACITY); |
36 | putTask(queue,type,task); | 36 | putTask(queue,type,task); |
37 | queueMap.putIfAbsent(type,queue); | 37 | queueMap.putIfAbsent(type,queue); |
38 | initQueue(type); | 38 | initQueue(type); |
@@ -128,6 +128,7 @@ public class ISearchConstans { | @@ -128,6 +128,7 @@ public class ISearchConstans { | ||
128 | idFieldMap.put(Index.store.getIndexName(), "id"); | 128 | idFieldMap.put(Index.store.getIndexName(), "id"); |
129 | idFieldMap.put(Index.topic.getIndexName(), "id"); | 129 | idFieldMap.put(Index.topic.getIndexName(), "id"); |
130 | idFieldMap.put(Index.social_user.getIndexName(), "id"); | 130 | idFieldMap.put(Index.social_user.getIndexName(), "id"); |
131 | + idFieldMap.put(Index.content.getIndexName(), "id"); | ||
131 | } | 132 | } |
132 | 133 | ||
133 | public static String getKeyField(final String indexName) { | 134 | public static String getKeyField(final String indexName) { |
@@ -28,7 +28,11 @@ public enum Index { | @@ -28,7 +28,11 @@ public enum Index { | ||
28 | /** | 28 | /** |
29 | * 资讯用户 | 29 | * 资讯用户 |
30 | */ | 30 | */ |
31 | - social_user("social_user","YH:MARS:SEARCH:LAST_UPDATE_TIME:SOCIAL_USER") | 31 | + social_user("social_user","YH:MARS:SEARCH:LAST_UPDATE_TIME:SOCIAL_USER"), |
32 | + /** | ||
33 | + * 资讯文章 | ||
34 | + */ | ||
35 | + content("content","YH:MARS:SEARCH:LAST_UPDATE_TIME:CONTENT") | ||
32 | ; | 36 | ; |
33 | 37 | ||
34 | 38 |
1 | +package com.yoho.search.dal; | ||
2 | + | ||
3 | +import com.yoho.search.dal.model.Content; | ||
4 | +import com.yoho.search.dal.model.ContentTag; | ||
5 | +import org.apache.ibatis.annotations.Param; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +public interface ContentMapper { | ||
10 | + | ||
11 | + int selectMinId(); | ||
12 | + | ||
13 | + int selectMaxId(); | ||
14 | + | ||
15 | + List<Content> selectListByRange(@Param(value = "minId") Integer minId, @Param(value = "maxId") Integer maxId); | ||
16 | + | ||
17 | + List<ContentTag> selectTagsByIds(@Param(value = "contentIds") List<Integer> contentIds); | ||
18 | +} |
1 | +package com.yoho.search.dal.model; | ||
2 | + | ||
3 | +import java.util.HashSet; | ||
4 | +import java.util.Set; | ||
5 | + | ||
6 | +/** | ||
7 | + * @author gris.wang | ||
8 | + * @since 2018/3/8 | ||
9 | + **/ | ||
10 | +public class Content { | ||
11 | + | ||
12 | + private Integer id; | ||
13 | + | ||
14 | + private Integer cid; | ||
15 | + | ||
16 | + private Integer type; | ||
17 | + | ||
18 | + private Integer app; | ||
19 | + | ||
20 | + private String title; | ||
21 | + | ||
22 | + private String cover; | ||
23 | + | ||
24 | + private String summary; | ||
25 | + | ||
26 | + private Integer relateAccount; | ||
27 | + | ||
28 | + private Set<Integer> tagIds; | ||
29 | + | ||
30 | + private Set<String> tagNames; | ||
31 | + | ||
32 | + private Integer tagCount = 0; | ||
33 | + | ||
34 | + public Integer getId() { | ||
35 | + return id; | ||
36 | + } | ||
37 | + | ||
38 | + public void setId(Integer id) { | ||
39 | + this.id = id; | ||
40 | + } | ||
41 | + | ||
42 | + public Integer getCid() { | ||
43 | + return cid; | ||
44 | + } | ||
45 | + | ||
46 | + public void setCid(Integer cid) { | ||
47 | + this.cid = cid; | ||
48 | + } | ||
49 | + | ||
50 | + public Integer getType() { | ||
51 | + return type; | ||
52 | + } | ||
53 | + | ||
54 | + public void setType(Integer type) { | ||
55 | + this.type = type; | ||
56 | + } | ||
57 | + | ||
58 | + public Integer getApp() { | ||
59 | + return app; | ||
60 | + } | ||
61 | + | ||
62 | + public void setApp(Integer app) { | ||
63 | + this.app = app; | ||
64 | + } | ||
65 | + | ||
66 | + public String getTitle() { | ||
67 | + return title; | ||
68 | + } | ||
69 | + | ||
70 | + public void setTitle(String title) { | ||
71 | + this.title = title; | ||
72 | + } | ||
73 | + | ||
74 | + public String getCover() { | ||
75 | + return cover; | ||
76 | + } | ||
77 | + | ||
78 | + public void setCover(String cover) { | ||
79 | + this.cover = cover; | ||
80 | + } | ||
81 | + | ||
82 | + public String getSummary() { | ||
83 | + return summary; | ||
84 | + } | ||
85 | + | ||
86 | + public void setSummary(String summary) { | ||
87 | + this.summary = summary; | ||
88 | + } | ||
89 | + | ||
90 | + public Integer getRelateAccount() { | ||
91 | + return relateAccount; | ||
92 | + } | ||
93 | + | ||
94 | + public void setRelateAccount(Integer relateAccount) { | ||
95 | + this.relateAccount = relateAccount; | ||
96 | + } | ||
97 | + | ||
98 | + public Set<Integer> getTagIds() { | ||
99 | + return tagIds; | ||
100 | + } | ||
101 | + | ||
102 | + public void setTagIds(Set<Integer> tagIds) { | ||
103 | + this.tagIds = tagIds; | ||
104 | + } | ||
105 | + | ||
106 | + public void addTagId(Integer tagId){ | ||
107 | + if(this.tagIds==null){ | ||
108 | + this.tagIds = new HashSet<>(); | ||
109 | + } | ||
110 | + this.tagIds.add(tagId); | ||
111 | + } | ||
112 | + | ||
113 | + public Set<String> getTagNames() { | ||
114 | + return tagNames; | ||
115 | + } | ||
116 | + | ||
117 | + public void setTagNames(Set<String> tagNames) { | ||
118 | + this.tagNames = tagNames; | ||
119 | + } | ||
120 | + | ||
121 | + public void addTagName(String tagName){ | ||
122 | + if(this.tagNames==null){ | ||
123 | + this.tagNames = new HashSet<>(); | ||
124 | + } | ||
125 | + this.tagNames.add(tagName); | ||
126 | + } | ||
127 | + | ||
128 | + public Integer getTagCount() { | ||
129 | + return tagCount; | ||
130 | + } | ||
131 | + | ||
132 | + public void setTagCount(Integer tagCount) { | ||
133 | + this.tagCount = tagCount; | ||
134 | + } | ||
135 | + | ||
136 | + public void increaseTagCount(Integer tagCount){ | ||
137 | + this.tagCount += tagCount; | ||
138 | + } | ||
139 | +} |
1 | +package com.yoho.search.dal.model; | ||
2 | + | ||
3 | +/** | ||
4 | + * @author gris.wang | ||
5 | + * @since 2018/3/8 | ||
6 | + **/ | ||
7 | +public class ContentTag{ | ||
8 | + | ||
9 | + private Integer cid; | ||
10 | + | ||
11 | + private Integer tagId; | ||
12 | + | ||
13 | + private String tagName; | ||
14 | + | ||
15 | + public Integer getCid() { | ||
16 | + return cid; | ||
17 | + } | ||
18 | + | ||
19 | + public void setCid(Integer cid) { | ||
20 | + this.cid = cid; | ||
21 | + } | ||
22 | + | ||
23 | + public Integer getTagId() { | ||
24 | + return tagId; | ||
25 | + } | ||
26 | + | ||
27 | + public void setTagId(Integer tagId) { | ||
28 | + this.tagId = tagId; | ||
29 | + } | ||
30 | + | ||
31 | + public String getTagName() { | ||
32 | + return tagName; | ||
33 | + } | ||
34 | + | ||
35 | + public void setTagName(String tagName) { | ||
36 | + this.tagName = tagName; | ||
37 | + } | ||
38 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.search.dal.ContentMapper"> | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.Content"> | ||
5 | + <result column="id" property="id" jdbcType="INTEGER"/> | ||
6 | + <result column="cid" property="cid" jdbcType="INTEGER"/> | ||
7 | + <result column="type" property="type" jdbcType="INTEGER"/> | ||
8 | + <result column="app" property="app" jdbcType="INTEGER"/> | ||
9 | + <result column="title" property="title" jdbcType="VARCHAR"/> | ||
10 | + <result column="cover" property="cover" jdbcType="VARCHAR"/> | ||
11 | + <result column="summary" property="summary" jdbcType="VARCHAR"/> | ||
12 | + <result column="relate_account" property="relateAccount" jdbcType="INTEGER"/> | ||
13 | + </resultMap> | ||
14 | + <resultMap id="ContentTagsResultMap" type="com.yoho.search.dal.model.ContentTag"> | ||
15 | + <result column="cid" property="cid" jdbcType="INTEGER"/> | ||
16 | + <result column="tag_id" property="tagId" jdbcType="INTEGER"/> | ||
17 | + <result column="tag_name" property="tagName" jdbcType="VARCHAR"/> | ||
18 | + </resultMap> | ||
19 | + <sql id="Base_Column_List"> | ||
20 | + id,cid,`type`,app,title,cover,summary,relate_account | ||
21 | + </sql> | ||
22 | + <select id="selectMinId" resultType="java.lang.Integer" timeout="20000"> | ||
23 | + SELECT min(id) FROM tbl_merge_content_merge | ||
24 | + </select> | ||
25 | + <select id="selectMaxId" resultType="java.lang.Integer" timeout="20000"> | ||
26 | + SELECT max(id) FROM tbl_merge_content_merge | ||
27 | + </select> | ||
28 | + <select id="selectListByRange" resultMap="BaseResultMap" timeout="20000"> | ||
29 | + select | ||
30 | + <include refid="Base_Column_List"/> | ||
31 | + from tbl_merge_content_merge | ||
32 | + where id BETWEEN #{minId} AND #{maxId} | ||
33 | + </select> | ||
34 | + <select id="selectTagsByIds" resultMap="ContentTagsResultMap" timeout="20000"> | ||
35 | + select ts.content_id as cid,t.id as tag_id,t.name as tag_name | ||
36 | + from tbl_tags t,tbl_tags_show ts | ||
37 | + where ts.tag_id=t.id and | ||
38 | + ts.content_id | ||
39 | + <foreach collection="contentIds" item="contentId" open="in (" separator="," close=")"> | ||
40 | + #{contentId} | ||
41 | + </foreach> | ||
42 | + union all | ||
43 | + select ts.content_id as cid,t.id as tag_id,t.name as tag_name | ||
44 | + from tbl_tags t,tbl_tags_show_girl ts | ||
45 | + where ts.tag_id=t.id and | ||
46 | + ts.content_id | ||
47 | + <foreach collection="contentIds" item="contentId" open="in (" separator="," close=")"> | ||
48 | + #{contentId} | ||
49 | + </foreach> | ||
50 | + </select> | ||
51 | +</mapper> |
@@ -25,21 +25,29 @@ public class IndexRebuildJob { | @@ -25,21 +25,29 @@ public class IndexRebuildJob { | ||
25 | 25 | ||
26 | 26 | ||
27 | /** | 27 | /** |
28 | - * 定时任务重建所有索引(每1小时执行一次) | 28 | + * 定时任务重建索引(每1小时执行一次) |
29 | + * 该索引数据量大 | ||
29 | */ | 30 | */ |
30 | @Scheduled(cron = "0 0 */1 * * ?") | 31 | @Scheduled(cron = "0 0 */1 * * ?") |
31 | public void rebuildIndexJob() { | 32 | public void rebuildIndexJob() { |
32 | this.rebuildIndex(Index.social_user); | 33 | this.rebuildIndex(Index.social_user); |
33 | } | 34 | } |
34 | 35 | ||
35 | - | ||
36 | /** | 36 | /** |
37 | - * 定时任务增量更新所有索引(每10分钟执行一次) | 37 | + * 定时任务重建索引(每10分钟执行一次) |
38 | + * 该索引数据量小 | ||
38 | */ | 39 | */ |
39 | @Scheduled(cron = "0 */10 * * * ?") | 40 | @Scheduled(cron = "0 */10 * * * ?") |
40 | - public void appendIndexJob() { | ||
41 | - // store的数据量少,也每10分钟直接重建一次 | 41 | + public void rebuildSmallIndexJob() { |
42 | this.rebuildIndex(Index.store); | 42 | this.rebuildIndex(Index.store); |
43 | + this.rebuildIndex(Index.content); | ||
44 | + } | ||
45 | + | ||
46 | + /** | ||
47 | + * 定时任务增量更新索引(每10分钟执行一次) | ||
48 | + */ | ||
49 | + @Scheduled(cron = "50 */10 * * * ?") | ||
50 | + public void appendIndexJob() { | ||
43 | this.appendIndex(Index.social_user); | 51 | this.appendIndex(Index.social_user); |
44 | } | 52 | } |
45 | 53 |
@@ -17,11 +17,12 @@ datasources: | @@ -17,11 +17,12 @@ datasources: | ||
17 | 17 | ||
18 | yh_cms: | 18 | yh_cms: |
19 | servers: | 19 | servers: |
20 | - - 172.16.4.138:3306 | ||
21 | - - 172.16.4.138:3306 | 20 | + - 192.168.102.17:3306 |
21 | + - 192.168.102.17:3306 | ||
22 | username: yh_test | 22 | username: yh_test |
23 | password: 9nm0icOwt6bMHjMusIfMLw== | 23 | password: 9nm0icOwt6bMHjMusIfMLw== |
24 | daos: | 24 | daos: |
25 | - com.yoho.search.dal.SocialUserDetailMapper | 25 | - com.yoho.search.dal.SocialUserDetailMapper |
26 | + - com.yoho.search.dal.ContentMapper | ||
26 | 27 | ||
27 | readOnlyInSlave: true | 28 | readOnlyInSlave: true |
1 | +{ | ||
2 | + "content": { | ||
3 | + "_all":{ | ||
4 | + "enabled":false | ||
5 | + }, | ||
6 | + "_source":{ | ||
7 | + "enabled":true | ||
8 | + }, | ||
9 | + "properties": { | ||
10 | + "id": { | ||
11 | + "type": "integer" | ||
12 | + }, | ||
13 | + "cid": { | ||
14 | + "type": "integer" | ||
15 | + }, | ||
16 | + "type": { | ||
17 | + "type": "integer" | ||
18 | + }, | ||
19 | + "app": { | ||
20 | + "type": "integer" | ||
21 | + }, | ||
22 | + "title":{ | ||
23 | + "type": "string", | ||
24 | + "analyzer": "ik_complex" | ||
25 | + }, | ||
26 | + "cover":{ | ||
27 | + "type": "string", | ||
28 | + "analyzer": "ik_complex" | ||
29 | + }, | ||
30 | + "summary":{ | ||
31 | + "type": "string", | ||
32 | + "analyzer": "ik_complex" | ||
33 | + }, | ||
34 | + "relate_account": { | ||
35 | + "type": "integer" | ||
36 | + }, | ||
37 | + "tag_ids":{ | ||
38 | + "type": "string", | ||
39 | + "index": "not_analyzed" | ||
40 | + }, | ||
41 | + "tag_names":{ | ||
42 | + "type": "string", | ||
43 | + "index": "not_analyzed" | ||
44 | + }, | ||
45 | + "tag_count": { | ||
46 | + "type": "integer" | ||
47 | + } | ||
48 | + } | ||
49 | + } | ||
50 | +} |
@@ -84,5 +84,18 @@ | @@ -84,5 +84,18 @@ | ||
84 | <appenderClass>com.yohomars.search.index.appender.impls.SocialUserIndexAppender</appenderClass> | 84 | <appenderClass>com.yohomars.search.index.appender.impls.SocialUserIndexAppender</appenderClass> |
85 | <mappingFile>esmapping/social_user.json</mappingFile> | 85 | <mappingFile>esmapping/social_user.json</mappingFile> |
86 | </index> | 86 | </index> |
87 | + | ||
88 | + <index> | ||
89 | + <name>content</name> | ||
90 | + <properties> | ||
91 | + <property key="number_of_shards" value="1"/> | ||
92 | + <property key="number_of_replicas" value="0"/> | ||
93 | + <property key="refresh_interval" value="10s"/> | ||
94 | + <property key="translog.flush_threshold_ops" value="5000"/> | ||
95 | + </properties> | ||
96 | + <builderClass>com.yohomars.search.index.builder.impls.ContentIndexBuilder</builderClass> | ||
97 | + <appenderClass>com.yohomars.search.index.appender.impls.ContentIndexAppender</appenderClass> | ||
98 | + <mappingFile>esmapping/content.json</mappingFile> | ||
99 | + </index> | ||
87 | </client> | 100 | </client> |
88 | </IndexConfigs> | 101 | </IndexConfigs> |
@@ -23,5 +23,6 @@ datasources: | @@ -23,5 +23,6 @@ datasources: | ||
23 | password: ${jdbc.mysql.yhnow.password} | 23 | password: ${jdbc.mysql.yhnow.password} |
24 | daos: | 24 | daos: |
25 | - com.yoho.search.dal.SocialUserDetailMapper | 25 | - com.yoho.search.dal.SocialUserDetailMapper |
26 | + - com.yoho.search.dal.ContentMapper | ||
26 | 27 | ||
27 | readOnlyInSlave: true | 28 | readOnlyInSlave: true |
@@ -84,5 +84,18 @@ | @@ -84,5 +84,18 @@ | ||
84 | <appenderClass>com.yohomars.search.index.appender.impls.SocialUserIndexAppender</appenderClass> | 84 | <appenderClass>com.yohomars.search.index.appender.impls.SocialUserIndexAppender</appenderClass> |
85 | <mappingFile>esmapping/social_user.json</mappingFile> | 85 | <mappingFile>esmapping/social_user.json</mappingFile> |
86 | </index> | 86 | </index> |
87 | + | ||
88 | + <index> | ||
89 | + <name>content</name> | ||
90 | + <properties> | ||
91 | + <property key="number_of_shards" value="1"/> | ||
92 | + <property key="number_of_replicas" value="${yohomarssearch.index.number_of_replicas}"/> | ||
93 | + <property key="refresh_interval" value="${yohomarssearch.index.refresh_interval}"/> | ||
94 | + <property key="translog.flush_threshold_ops" value="${yohomarssearch.index.translog.flush_threshold_ops}"/> | ||
95 | + </properties> | ||
96 | + <builderClass>com.yohomars.search.index.builder.impls.ContentIndexBuilder</builderClass> | ||
97 | + <appenderClass>com.yohomars.search.index.appender.impls.ContentIndexAppender</appenderClass> | ||
98 | + <mappingFile>esmapping/content.json</mappingFile> | ||
99 | + </index> | ||
87 | </client> | 100 | </client> |
88 | </IndexConfigs> | 101 | </IndexConfigs> |
-
Please register or login to post a comment