Authored by hugufei

去除config.properties中所有无用的配置

@@ -2,6 +2,7 @@ package com.yoho.search.service.helper; @@ -2,6 +2,7 @@ package com.yoho.search.service.helper;
2 2
3 import com.yoho.search.base.utils.*; 3 import com.yoho.search.base.utils.*;
4 import com.yoho.search.common.SearchServiceConfiger; 4 import com.yoho.search.common.SearchServiceConfiger;
  5 +import com.yoho.search.core.es.utils.SearchFieldUtils;
5 import com.yoho.search.service.base.SearchDynamicConfigService; 6 import com.yoho.search.service.base.SearchDynamicConfigService;
6 import com.yoho.search.service.base.SearchRequestParams; 7 import com.yoho.search.service.base.SearchRequestParams;
7 import org.apache.commons.collections.MapUtils; 8 import org.apache.commons.collections.MapUtils;
@@ -325,22 +326,7 @@ public class SearchCommonHelper { @@ -325,22 +326,7 @@ public class SearchCommonHelper {
325 // 获取MultiMatchQueryBuilder的类型 326 // 获取MultiMatchQueryBuilder的类型
326 public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() { 327 public MultiMatchQueryBuilder.Type getMultiMatchQueryBuilderType() {
327 String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType(); 328 String configMultiMatchQueryType = searchServiceConfiger.getSearchMultiMatchQueryType();
328 - if (configMultiMatchQueryType.equalsIgnoreCase(MultiMatchQueryBuilder.Type.BEST_FIELDS.name())) {  
329 - return MultiMatchQueryBuilder.Type.BEST_FIELDS;  
330 - }  
331 - if (configMultiMatchQueryType.equalsIgnoreCase(MultiMatchQueryBuilder.Type.MOST_FIELDS.name())) {  
332 - return MultiMatchQueryBuilder.Type.MOST_FIELDS;  
333 - }  
334 - if (configMultiMatchQueryType.equalsIgnoreCase(MultiMatchQueryBuilder.Type.CROSS_FIELDS.name())) {  
335 - return MultiMatchQueryBuilder.Type.CROSS_FIELDS;  
336 - }  
337 - if (configMultiMatchQueryType.equalsIgnoreCase(MultiMatchQueryBuilder.Type.PHRASE.name())) {  
338 - return MultiMatchQueryBuilder.Type.PHRASE;  
339 - }  
340 - if (configMultiMatchQueryType.equalsIgnoreCase(MultiMatchQueryBuilder.Type.PHRASE_PREFIX.name())) {  
341 - return MultiMatchQueryBuilder.Type.PHRASE_PREFIX;  
342 - }  
343 - return null; 329 + return SearchFieldUtils.getMultiMatchQueryBuilderType(configMultiMatchQueryType);
344 } 330 }
345 331
346 /** 332 /**
1 package com.yoho.search.service.helper; 1 package com.yoho.search.service.helper;
2 2
3 -import com.yoho.search.base.beans.SearchPropertyPlaceholderConfigurer;  
4 import com.yoho.search.base.constants.ProductModelValueConstants; 3 import com.yoho.search.base.constants.ProductModelValueConstants;
5 import com.yoho.search.base.utils.ConvertUtils; 4 import com.yoho.search.base.utils.ConvertUtils;
6 import com.yoho.search.base.utils.DateUtil; 5 import com.yoho.search.base.utils.DateUtil;
7 -import com.yoho.search.base.utils.ISearchConstants;  
8 import com.yoho.search.base.utils.ProductIndexEsField; 6 import com.yoho.search.base.utils.ProductIndexEsField;
9 import com.yoho.search.common.SearchServiceConfiger; 7 import com.yoho.search.common.SearchServiceConfiger;
10 import com.yoho.search.common.utils.SearchKeyWordUtils; 8 import com.yoho.search.common.utils.SearchKeyWordUtils;
11 import com.yoho.search.core.es.model.SearchField; 9 import com.yoho.search.core.es.model.SearchField;
12 -import com.yoho.search.core.es.utils.SearchFieldFactory; 10 +import com.yoho.search.core.es.utils.SearchFieldUtils;
13 import com.yoho.search.service.base.SearchRequestParams; 11 import com.yoho.search.service.base.SearchRequestParams;
14 import org.apache.commons.lang.StringUtils; 12 import org.apache.commons.lang.StringUtils;
15 import org.apache.lucene.search.join.ScoreMode; 13 import org.apache.lucene.search.join.ScoreMode;
@@ -96,7 +94,7 @@ public class SearchServiceHelper { @@ -96,7 +94,7 @@ public class SearchServiceHelper {
96 * @param queryBuilder 94 * @param queryBuilder
97 */ 95 */
98 private void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder) { 96 private void setDefaultSearchField(MultiMatchQueryBuilder queryBuilder) {
99 - List<SearchField> fuzzySearchFields = SearchFieldFactory.getFuzzySearchFields(); 97 + List<SearchField> fuzzySearchFields = SearchFieldUtils.getFuzzySearchFields();
100 for (SearchField searchField : fuzzySearchFields) { 98 for (SearchField searchField : fuzzySearchFields) {
101 queryBuilder.field(searchField.getEsField(),searchField.getBoost()); 99 queryBuilder.field(searchField.getEsField(),searchField.getBoost());
102 } 100 }
@@ -10,7 +10,7 @@ import com.yoho.search.core.es.IElasticsearchClient; @@ -10,7 +10,7 @@ import com.yoho.search.core.es.IElasticsearchClient;
10 import com.yoho.search.core.es.model.SearchField; 10 import com.yoho.search.core.es.model.SearchField;
11 import com.yoho.search.core.es.model.SearchParam; 11 import com.yoho.search.core.es.model.SearchParam;
12 import com.yoho.search.core.es.model.SearchResult; 12 import com.yoho.search.core.es.model.SearchResult;
13 -import com.yoho.search.core.es.utils.SearchFieldFactory; 13 +import com.yoho.search.core.es.utils.SearchFieldUtils;
14 import com.yoho.search.service.base.ESClientMgr; 14 import com.yoho.search.service.base.ESClientMgr;
15 import com.yoho.search.service.searchexplainer.models.*; 15 import com.yoho.search.service.searchexplainer.models.*;
16 import org.apache.commons.collections.CollectionUtils; 16 import org.apache.commons.collections.CollectionUtils;
@@ -688,7 +688,7 @@ public class SearchExplainerService { @@ -688,7 +688,7 @@ public class SearchExplainerService {
688 return localMutilFields; 688 return localMutilFields;
689 } 689 }
690 List<FieldWithBoost> list = new ArrayList<>(); 690 List<FieldWithBoost> list = new ArrayList<>();
691 - List<SearchField> searchFields = SearchFieldFactory.getFuzzySearchFields(); 691 + List<SearchField> searchFields = SearchFieldUtils.getFuzzySearchFields();
692 for (SearchField searchField : searchFields) { 692 for (SearchField searchField : searchFields) {
693 list.add(new FieldWithBoost(searchField.getEsField(), (int)searchField.getBoost())); 693 list.add(new FieldWithBoost(searchField.getEsField(), (int)searchField.getBoost()));
694 } 694 }
@@ -8,7 +8,7 @@ import com.yoho.search.common.utils.SearchKeyWordUtils; @@ -8,7 +8,7 @@ import com.yoho.search.common.utils.SearchKeyWordUtils;
8 import com.yoho.search.core.es.model.SearchField; 8 import com.yoho.search.core.es.model.SearchField;
9 import com.yoho.search.core.es.model.SearchParam; 9 import com.yoho.search.core.es.model.SearchParam;
10 import com.yoho.search.core.es.model.SearchResult; 10 import com.yoho.search.core.es.model.SearchResult;
11 -import com.yoho.search.core.es.utils.SearchFieldFactory; 11 +import com.yoho.search.core.es.utils.SearchFieldUtils;
12 import com.yoho.search.models.SearchApiResult; 12 import com.yoho.search.models.SearchApiResult;
13 import com.yoho.search.models.SearchSort; 13 import com.yoho.search.models.SearchSort;
14 import com.yoho.search.service.base.SearchCommonService; 14 import com.yoho.search.service.base.SearchCommonService;
@@ -40,7 +40,6 @@ import org.elasticsearch.search.sort.SortOrder; @@ -40,7 +40,6 @@ import org.elasticsearch.search.sort.SortOrder;
40 import org.springframework.beans.factory.annotation.Autowired; 40 import org.springframework.beans.factory.annotation.Autowired;
41 import org.springframework.stereotype.Service; 41 import org.springframework.stereotype.Service;
42 42
43 -import javax.annotation.PostConstruct;  
44 import java.util.*; 43 import java.util.*;
45 44
46 @Service 45 @Service
@@ -69,7 +68,7 @@ public class ShopListServiceImpl implements IShopListService { @@ -69,7 +68,7 @@ public class ShopListServiceImpl implements IShopListService {
69 // 2、构建query 68 // 2、构建query
70 MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword); 69 MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(keyword);
71 queryBuilder.operator(Operator.OR); 70 queryBuilder.operator(Operator.OR);
72 - List<SearchField> shopSearchFields = SearchFieldFactory.getShopNameSearchFields(); 71 + List<SearchField> shopSearchFields = SearchFieldUtils.getShopNameSearchFields();
73 for (SearchField searchField: shopSearchFields) { 72 for (SearchField searchField: shopSearchFields) {
74 queryBuilder.field(searchField.getEsField(), searchField.getBoost()); 73 queryBuilder.field(searchField.getEsField(), searchField.getBoost());
75 } 74 }
@@ -19,11 +19,8 @@ search.index.refresh_interval = 1 @@ -19,11 +19,8 @@ search.index.refresh_interval = 1
19 search.index.translog.flush_threshold_ops = 5000 19 search.index.translog.flush_threshold_ops = 5000
20 20
21 #search 21 #search
22 -search.minimum.should.match=75%  
23 -search.operator=and  
24 -search.default.field=productName_ansj^10,brandName^500,brandDomain^100,brandNameCn^100,brandNameEn^100,maxSort^300,middleSort^500,smallSort^1000,searchField_ansj,productSkn_ansj,brandNameCn_pinyin^100,maxSort_pinyin^300,middleSort_pinyin^500,smallSort_pinyin^1000,productKeyword^500,brandKeyword^50,searchField  
25 -search.script.score=_score+doc['sortWeight'].value*0.003+(100-doc['breakingRate'].value)/100 * doc['salesWithDateDiff'].value/pow((now-doc['shelveTime'].value)/3600+2,1.8)  
26 -search.script.lang=groovy 22 +search.minimum.should.match=3<90%
  23 +search.operator=or
27 search.multiMatchQuery.type=CROSS_FIELDS 24 search.multiMatchQuery.type=CROSS_FIELDS
28 25
29 ##tpl adaptor 26 ##tpl adaptor
1 -#redis  
2 -redis.proxy.address=192.168.102.211  
3 -redis.proxy.port=6379  
4 -redis.proxy.auth=  
5 -redis.readonly.proxy.address=192.168.102.211  
6 -redis.readonly.proxy.port=6379  
7 -redis.readonly.proxy.auth=  
8 -  
9 -#redis notsync  
10 -redis.notsync.twemproxy.addresses=192.168.102.211:6379  
11 -redis.notsync.twemproxy.auth=  
12 -  
13 -#bigData - redis servers  
14 -bigDataRedis-search.proxy.address=123.206.17.17  
15 -bigDataRedis-search.proxy.port=16379  
16 -bigDataRedis-search.proxy.auth=  
17 -  
18 -#search redis  
19 -redis.search.proxy.address =192.168.102.216  
20 -redis.search.proxy.port =6379  
21 -redis.search.proxy.auth =  
22 -  
23 #es.cluster 1 #es.cluster
24 search.es.cluster.name=yohosearch_test 2 search.es.cluster.name=yohosearch_test
25 search.es.servers=192.168.102.209:9300 192.168.102.216:9300 3 search.es.servers=192.168.102.209:9300 192.168.102.216:9300
26 -search.index.number_of_replicas=0  
27 -search.index.refresh_interval=10s  
28 -search.index.translog.flush_threshold_ops=10000  
29 4
30 #search 5 #search
31 search.minimum.should.match=3<90% 6 search.minimum.should.match=3<90%
32 search.operator=or 7 search.operator=or
33 -search.script.lang=groovy  
34 -  
35 -search.use.cache=true  
36 -search.cache.type=redisCache  
37 -  
38 -#personalized search  
39 -search.personalized.switch=true  
40 -search.personalized.max.should=50  
41 -  
42 -tpl.adaptor.valid=true  
43 -  
44 search.multiMatchQuery.type=CROSS_FIELDS 8 search.multiMatchQuery.type=CROSS_FIELDS
45 9
46 -search.open.downgrade=true  
47 - 10 +##cache
  11 +search.use.cache=true
48 12
49 #zkAddress 13 #zkAddress
50 zkAddress=192.168.102.216:2181 14 zkAddress=192.168.102.216:2181
1 -#redis  
2 -redis.proxy.address=${redis.proxy.address}  
3 -redis.proxy.port=${redis.proxy.port}  
4 -redis.proxy.auth=${redis.proxy.auth}  
5 -redis.readonly.proxy.address=${redis.readonly.proxy.address}  
6 -redis.readonly.proxy.port=${redis.readonly.proxy.port}  
7 -redis.readonly.proxy.auth=${redis.readonly.proxy.auth}  
8 -  
9 -#redis notsync  
10 -redis.notsync.twemproxy.addresses=${redis.notsync.twemproxy.addresses}  
11 -redis.notsync.twemproxy.auth=${redis.notsync.twemproxy.auth}  
12 -  
13 -#bigData - redis servers  
14 -bigDataRedis-search.proxy.address=${bigDataRedis-search.proxy.address}  
15 -bigDataRedis-search.proxy.port=${bigDataRedis-search.proxy.port}  
16 -bigDataRedis-search.proxy.auth=${bigDataRedis-search.proxy.auth}  
17 -  
18 -#search redis  
19 -redis.search.proxy.address=${redis.search.proxy.address}  
20 -redis.search.proxy.port=${redis.search.proxy.port}  
21 -redis.search.proxy.auth=${redis.search.proxy.auth}  
22 -  
23 #es.cluster 1 #es.cluster
24 search.es.cluster.name=${search.es.cluster.name} 2 search.es.cluster.name=${search.es.cluster.name}
25 search.es.servers=${search.es.servers} 3 search.es.servers=${search.es.servers}
26 -search.index.number_of_replicas=${search.index.number_of_replicas}  
27 -search.index.refresh_interval=${search.index.refresh_interval}  
28 -search.index.translog.flush_threshold_ops=${search.index.translog.flush_threshold_ops}  
29 4
30 #search 5 #search
31 search.minimum.should.match=3<90% 6 search.minimum.should.match=3<90%
32 search.operator=or 7 search.operator=or
33 -search.script.lang=groovy 8 +search.multiMatchQuery.type=CROSS_FIELDS
34 9
  10 +##cache
35 search.use.cache=true 11 search.use.cache=true
36 -search.cache.type=${search.cache.type}  
37 -  
38 -#personalized search  
39 -search.personalized.switch=${search.personalized.switch}  
40 -search.personalized.max.should=${search.personalized.max.should}  
41 -  
42 -tpl.adaptor.valid=${tpl.adaptor.valid}  
43 -  
44 -search.multiMatchQuery.type=${search.multiMatchQuery.type}  
45 -  
46 -search.open.downgrade=${search.open.downgrade}  
47 -  
48 -  
49 -#profile.threshold  
50 -profile.threshold=500  
51 12
52 #zkAddress 13 #zkAddress
53 zkAddress=${zkAddress} 14 zkAddress=${zkAddress}
54 15
55 #web.content 16 #web.content
56 -web.context=yohosearch  
  17 +web.context=yohosearch
  18 +
  19 +#profile.threshold
  20 +profile.threshold=500