1
|
package com.yoho.search.service.restapi;
|
1
|
package com.yoho.search.service.restapi;
|
2
|
|
2
|
|
3
|
-import java.util.ArrayList;
|
|
|
4
|
-import java.util.List;
|
|
|
5
|
-import java.util.Map;
|
|
|
6
|
-
|
3
|
+import com.yoho.search.service.cache.LocalCacheService;
|
|
|
4
|
+import com.yoho.search.service.personalized.PersonalVectorFeatureSearch;
|
|
|
5
|
+import com.yoho.search.service.service.SearchKeyWordService;
|
|
|
6
|
+import com.yoho.search.service.servicenew.IProductListService;
|
|
|
7
|
+import com.yoho.search.service.vo.KeyWordWithCount;
|
|
|
8
|
+import com.yoho.search.service.vo.SearchApiResult;
|
7
|
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken;
|
9
|
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken;
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
import org.springframework.stereotype.Controller;
|
11
|
import org.springframework.stereotype.Controller;
|
|
@@ -12,12 +14,9 @@ import org.springframework.web.bind.annotation.RequestMethod; |
|
@@ -12,12 +14,9 @@ import org.springframework.web.bind.annotation.RequestMethod; |
12
|
import org.springframework.web.bind.annotation.RequestParam;
|
14
|
import org.springframework.web.bind.annotation.RequestParam;
|
13
|
import org.springframework.web.bind.annotation.ResponseBody;
|
15
|
import org.springframework.web.bind.annotation.ResponseBody;
|
14
|
|
16
|
|
15
|
-import com.yoho.search.service.cache.LocalCacheService;
|
|
|
16
|
-import com.yoho.search.service.personalized.PersonalVectorFeatureSearch;
|
|
|
17
|
-import com.yoho.search.service.service.SearchKeyWordService;
|
|
|
18
|
-import com.yoho.search.service.servicenew.IProductListService;
|
|
|
19
|
-import com.yoho.search.service.vo.KeyWordWithCount;
|
|
|
20
|
-import com.yoho.search.service.vo.SearchApiResult;
|
17
|
+import java.util.ArrayList;
|
|
|
18
|
+import java.util.List;
|
|
|
19
|
+import java.util.Map;
|
21
|
|
20
|
|
22
|
@Controller
|
21
|
@Controller
|
23
|
@RequestMapping(value = "/tools")
|
22
|
@RequestMapping(value = "/tools")
|
|
@@ -50,7 +49,7 @@ public class ToolsController { |
|
@@ -50,7 +49,7 @@ public class ToolsController { |
50
|
}
|
49
|
}
|
51
|
|
50
|
|
52
|
List<String> keywords = new ArrayList<>();
|
51
|
List<String> keywords = new ArrayList<>();
|
53
|
- for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>)results.get("-1")) {
|
52
|
+ for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>) results.get("-1")) {
|
54
|
keywords.add(keyWordWithCount.getKeyWord());
|
53
|
keywords.add(keyWordWithCount.getKeyWord());
|
55
|
}
|
54
|
}
|
56
|
return searchApiResult.setData(keywords);
|
55
|
return searchApiResult.setData(keywords);
|
|
@@ -58,6 +57,7 @@ public class ToolsController { |
|
@@ -58,6 +57,7 @@ public class ToolsController { |
58
|
|
57
|
|
59
|
/**
|
58
|
/**
|
60
|
* 获取空结果搜索词
|
59
|
* 获取空结果搜索词
|
|
|
60
|
+ *
|
61
|
* @return
|
61
|
* @return
|
62
|
*/
|
62
|
*/
|
63
|
@RequestMapping(method = RequestMethod.GET, value = "/emptyResultKeywords")
|
63
|
@RequestMapping(method = RequestMethod.GET, value = "/emptyResultKeywords")
|
|
@@ -72,7 +72,7 @@ public class ToolsController { |
|
@@ -72,7 +72,7 @@ public class ToolsController { |
72
|
}
|
72
|
}
|
73
|
|
73
|
|
74
|
List<String> keywords = new ArrayList<>();
|
74
|
List<String> keywords = new ArrayList<>();
|
75
|
- for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>)results.get("-1")) {
|
75
|
+ for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>) results.get("-1")) {
|
76
|
keywords.add(keyWordWithCount.getKeyWord());
|
76
|
keywords.add(keyWordWithCount.getKeyWord());
|
77
|
}
|
77
|
}
|
78
|
return searchApiResult.setData(keywords);
|
78
|
return searchApiResult.setData(keywords);
|
|
@@ -96,13 +96,25 @@ public class ToolsController { |
|
@@ -96,13 +96,25 @@ public class ToolsController { |
96
|
}
|
96
|
}
|
97
|
|
97
|
|
98
|
List<String> keywords = new ArrayList<>();
|
98
|
List<String> keywords = new ArrayList<>();
|
99
|
- for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>)results.get("-1")) {
|
99
|
+ for (KeyWordWithCount keyWordWithCount : (List<KeyWordWithCount>) results.get("-1")) {
|
100
|
keywords.add(keyWordWithCount.getKeyWord());
|
100
|
keywords.add(keyWordWithCount.getKeyWord());
|
101
|
}
|
101
|
}
|
102
|
return searchApiResult.setData(keywords);
|
102
|
return searchApiResult.setData(keywords);
|
103
|
}
|
103
|
}
|
104
|
|
104
|
|
105
|
/**
|
105
|
/**
|
|
|
106
|
+ * 删除redis上的key
|
|
|
107
|
+ * @param redisKey
|
|
|
108
|
+ * @return
|
|
|
109
|
+ */
|
|
|
110
|
+ @RequestMapping(method = RequestMethod.GET, value = "/deleteRedis")
|
|
|
111
|
+ @ResponseBody
|
|
|
112
|
+ public SearchApiResult deleteRedisKey(@RequestParam String redisKey) {
|
|
|
113
|
+ SearchApiResult searchApiResult = new SearchApiResult();
|
|
|
114
|
+ return searchApiResult.setData(searchKeyWordService.deleteRedisKey(redisKey));
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ /**
|
106
|
* 获取分词结果
|
118
|
* 获取分词结果
|
107
|
*
|
119
|
*
|
108
|
* @param request
|
120
|
* @param request
|
|
@@ -119,8 +131,7 @@ public class ToolsController { |
|
@@ -119,8 +131,7 @@ public class ToolsController { |
119
|
/**
|
131
|
/**
|
120
|
* 清除本地缓存
|
132
|
* 清除本地缓存
|
121
|
*
|
133
|
*
|
122
|
- * @param request
|
|
|
123
|
- * 请求
|
134
|
+ * @param request 请求
|
124
|
* @return
|
135
|
* @return
|
125
|
*/
|
136
|
*/
|
126
|
@RequestMapping(method = RequestMethod.GET, value = "/clearLocalCache")
|
137
|
@RequestMapping(method = RequestMethod.GET, value = "/clearLocalCache")
|