Authored by hugufei

no message

... ... @@ -16,7 +16,6 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.index.query.BoolFilterBuilder;
import org.elasticsearch.index.query.FilterBuilder;
import org.elasticsearch.index.query.FilterBuilders;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
... ... @@ -96,7 +95,7 @@ public class SearchService {
jsonMap.put("data", "");
return jsonMap;
}
//获取聚合结果
// 获取聚合结果
Object discountAggResult = discountAggregation.getAggregationResponseMap(searchResult.getAggMaps());
if (discountAggResult != null) {
Map<String, Object> filter = new HashMap<String, Object>();
... ... @@ -384,7 +383,7 @@ public class SearchService {
searchParam.setAggregationBuilders(Arrays.asList(aggregationBuilder));
searchParam.setSearchType(SearchType.COUNT);
//查询
// 查询
final String indexName = ISearchConstans.INDEX_NAME_PRODUCT_INDEX;
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
Map<String, Object> jsonMap = new HashMap<String, Object>();
... ... @@ -436,6 +435,10 @@ public class SearchService {
String[] genders = paramMap.get(ISearchConstans.PARAM_SEARCH_GENDER).split(",");
boolFilter.must(FilterBuilders.termsFilter("gender", genders));
}
// 如果contain_global!=Y,则过滤掉全球购的商品[全球购商品融合需求]
if (!paramMap.containsKey("contain_global") || !"Y".equals(paramMap.get("contain_global")) || !ISearchConstans.SEARCH_CONTAIL_GLOBAL) {
boolFilter.must(FilterBuilders.termsFilter("isGlobal", "N"));
}
if (boolFilter.hasClauses()) {
searchParam.setFiter(boolFilter);
}
... ... @@ -628,9 +631,13 @@ public class SearchService {
}
queryBuilder.minimumShouldMatch(ISearchConstans.SEARCH_MINIMUM_SHOULD_MATCH);
searchParam.setQuery(queryBuilder);
FilterBuilder filterBuilder = FilterBuilders.boolFilter().must(FilterBuilders.termFilter("status", 1)).mustNot(FilterBuilders.termFilter("attribute", 2))
BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter().must(FilterBuilders.termFilter("status", 1)).mustNot(FilterBuilders.termFilter("attribute", 2))
.must(FilterBuilders.rangeFilter("storageNum").gte(1)).must(FilterBuilders.termFilter("isOutlets", 2));
searchParam.setFiter(filterBuilder);
// 如果contain_global!=Y,则过滤掉全球购的商品[全球购商品融合需求]
if (!paramMap.containsKey("contain_global") || !"Y".equals(paramMap.get("contain_global")) || !ISearchConstans.SEARCH_CONTAIL_GLOBAL) {
boolFilterBuilder.must(FilterBuilders.termsFilter("isGlobal", "N"));
}
searchParam.setFiter(boolFilterBuilder);
searchParam.setSearchType(SearchType.COUNT);
final String indexName = ISearchConstans.INDEX_NAME_PRODUCT_INDEX;
SearchResult searchResult = searchCommonService.doSearch(indexName, searchParam);
... ...
... ... @@ -365,10 +365,10 @@ public class SearchServiceHelper {
boolFilter.must(FilterBuilders.termsFilter("productSkn", sknString.split(",")));
}
// // 如果contain_global!=Y,则过滤掉全球购的商品[全球购商品融合需求]
// if (!paramMap.containsKey("contain_global") || !"Y".equals(paramMap.get("contain_global"))) {
// boolFilter.must(FilterBuilders.termsFilter("isGlobal", "N"));
// }
// 如果contain_global!=Y,则过滤掉全球购的商品[全球购商品融合需求]
if (!paramMap.containsKey("contain_global") || !"Y".equals(paramMap.get("contain_global")) || !ISearchConstans.SEARCH_CONTAIL_GLOBAL) {
boolFilter.must(FilterBuilders.termsFilter("isGlobal", "N"));
}
// 通用的过滤请求
for (String key : paramMap.keySet()) {
... ...
... ... @@ -17,12 +17,17 @@ search.index.batch.limit.tbl=2000
search.index.batch.max.thread.size=10
search.minimum.should.match=75%
search.operator=and
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,searchField
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)
search.script.lang=groovy
search.contain.global=true
#zkAddress
zkAddress=192.168.102.205:2181
#web.content
web.context=yohosearch
... ...
... ... @@ -19,6 +19,7 @@
<property name="search.default.field" defaultValue="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^500,searchField" description="" />
<property name="search.script.score" defaultValue="_score+doc['sortWeight'].value*0.003+(100-doc['breakingRate'].value)/100 * doc['salesWithDateDiff'].value/pow((now-doc['shelveTime'].value)/3600+2,1.8)" description="" />
<property name="search.script.lang" defaultValue="groovy" description="" />
<property name="search.contain.global" defaultValue="true" description="搜索结果包含全球购是否生效" />
<property name="jdbc.mysql.yhbsearch.datasources" defaultValue="yhb_search_2016" description="" />
<property name="jdbc.mysql.yhbsearch.master" defaultValue="192.168.102.216:3306" description="" />
... ...
... ... @@ -21,6 +21,8 @@ search.default.field=${search.default.field}
search.script.score=${search.script.score}
search.script.lang=${search.script.lang}
search.contain.global=${search.contain.global}
#zkAddress
zkAddress=${zkAddress}
... ...