Authored by 胡古飞

add explain log

package com.yoho.search.service.searchexplainer;
import com.carrotsearch.hppc.ObjectLookupContainer;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.IElasticsearchClient;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.service.service.ESClientMgr;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse;
... ... @@ -20,11 +26,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON;
import com.carrotsearch.hppc.ObjectLookupContainer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.core.es.IElasticsearchClient;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.service.service.ESClientMgr;
/**
* Created by ginozhang on 2016/11/16.
... ... @@ -183,6 +194,9 @@ public class SearchExplainerService {
map.put("data", resultList);
map.put("searchTokens", searchTokens);
map.put("queryMatchResult", queryMatchResult);
logger.warn("explain show info with JSON is :" + JSON.toJSONString(map));
logger.warn("explain show info with ObjectMapper is :" + new ObjectMapper().writeValueAsString(map));
logger.info("End to show skn tokens. skn={}, keyword={}, cost={}.", skn, keyword, System.currentTimeMillis() - start);
return map;
... ... @@ -203,7 +217,7 @@ public class SearchExplainerService {
return searchFieldResult;
}
public Map<String, Object> explain(Map<String, String> paramMap) throws Exception {
long start = System.currentTimeMillis();
logger.info("Begin to explain search. start: {}, paramMap: {}.", start, paramMap);
... ...