Showing
1 changed file
with
28 additions
and
14 deletions
1 | package com.yoho.search.service.searchexplainer; | 1 | package com.yoho.search.service.searchexplainer; |
2 | 2 | ||
3 | -import com.carrotsearch.hppc.ObjectLookupContainer; | ||
4 | -import com.google.common.cache.CacheBuilder; | ||
5 | -import com.google.common.cache.CacheLoader; | ||
6 | -import com.yoho.search.base.utils.ISearchConstants; | ||
7 | -import com.yoho.search.core.es.IElasticsearchClient; | ||
8 | -import com.yoho.search.core.es.model.SearchParam; | ||
9 | -import com.yoho.search.core.es.model.SearchResult; | ||
10 | -import com.yoho.search.service.service.ESClientMgr; | 3 | +import java.io.IOException; |
4 | +import java.util.ArrayList; | ||
5 | +import java.util.Arrays; | ||
6 | +import java.util.Collections; | ||
7 | +import java.util.HashMap; | ||
8 | +import java.util.HashSet; | ||
9 | +import java.util.LinkedHashMap; | ||
10 | +import java.util.List; | ||
11 | +import java.util.Map; | ||
12 | +import java.util.Set; | ||
13 | +import java.util.concurrent.ExecutionException; | ||
14 | +import java.util.concurrent.TimeUnit; | ||
15 | +import java.util.stream.Collectors; | ||
16 | + | ||
11 | import org.apache.commons.collections.CollectionUtils; | 17 | import org.apache.commons.collections.CollectionUtils; |
12 | import org.apache.commons.lang3.StringUtils; | 18 | import org.apache.commons.lang3.StringUtils; |
13 | import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; | 19 | import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; |
@@ -20,11 +26,16 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -20,11 +26,16 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
20 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
21 | import org.springframework.util.Assert; | 27 | import org.springframework.util.Assert; |
22 | 28 | ||
23 | -import java.io.IOException; | ||
24 | -import java.util.*; | ||
25 | -import java.util.concurrent.ExecutionException; | ||
26 | -import java.util.concurrent.TimeUnit; | ||
27 | -import java.util.stream.Collectors; | 29 | +import com.alibaba.fastjson.JSON; |
30 | +import com.carrotsearch.hppc.ObjectLookupContainer; | ||
31 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
32 | +import com.google.common.cache.CacheBuilder; | ||
33 | +import com.google.common.cache.CacheLoader; | ||
34 | +import com.yoho.search.base.utils.ISearchConstants; | ||
35 | +import com.yoho.search.core.es.IElasticsearchClient; | ||
36 | +import com.yoho.search.core.es.model.SearchParam; | ||
37 | +import com.yoho.search.core.es.model.SearchResult; | ||
38 | +import com.yoho.search.service.service.ESClientMgr; | ||
28 | 39 | ||
29 | /** | 40 | /** |
30 | * Created by ginozhang on 2016/11/16. | 41 | * Created by ginozhang on 2016/11/16. |
@@ -183,6 +194,9 @@ public class SearchExplainerService { | @@ -183,6 +194,9 @@ public class SearchExplainerService { | ||
183 | map.put("data", resultList); | 194 | map.put("data", resultList); |
184 | map.put("searchTokens", searchTokens); | 195 | map.put("searchTokens", searchTokens); |
185 | map.put("queryMatchResult", queryMatchResult); | 196 | map.put("queryMatchResult", queryMatchResult); |
197 | + | ||
198 | + logger.warn("explain show info with JSON is :" + JSON.toJSONString(map)); | ||
199 | + logger.warn("explain show info with ObjectMapper is :" + new ObjectMapper().writeValueAsString(map)); | ||
186 | 200 | ||
187 | logger.info("End to show skn tokens. skn={}, keyword={}, cost={}.", skn, keyword, System.currentTimeMillis() - start); | 201 | logger.info("End to show skn tokens. skn={}, keyword={}, cost={}.", skn, keyword, System.currentTimeMillis() - start); |
188 | return map; | 202 | return map; |
@@ -203,7 +217,7 @@ public class SearchExplainerService { | @@ -203,7 +217,7 @@ public class SearchExplainerService { | ||
203 | 217 | ||
204 | return searchFieldResult; | 218 | return searchFieldResult; |
205 | } | 219 | } |
206 | - | 220 | + |
207 | public Map<String, Object> explain(Map<String, String> paramMap) throws Exception { | 221 | public Map<String, Object> explain(Map<String, String> paramMap) throws Exception { |
208 | long start = System.currentTimeMillis(); | 222 | long start = System.currentTimeMillis(); |
209 | logger.info("Begin to explain search. start: {}, paramMap: {}.", start, paramMap); | 223 | logger.info("Begin to explain search. start: {}, paramMap: {}.", start, paramMap); |
-
Please register or login to post a comment