Commit c31088f6 by 徐鹏

Merge branch 'TECH-search-fix' into 'master'

优化suggest算分逻辑

See merge request !3
parents ad678bb3 ee83a057
package com.secoo.so.suggest.entity;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.io.Serializable;
......@@ -33,5 +34,24 @@ public class EsSuggestKeywordInfo implements Serializable {
private String suggestTags;
private Long updateTime;
@JSONField(serialize = false)
private Long monthPv;
@JSONField(serialize = false)
private Long monthProductClickCount;
@JSONField(serialize = false)
private Long monthAddCartCount;
@JSONField(serialize = false)
private Long monthUv;
@JSONField(serialize = false)
private Long monthProductClickUv;
@JSONField(serialize = false)
private Long monthAddCartUv;
@JSONField(serialize = false)
private Long weekAddCartCount;
@JSONField(serialize = false)
private Long weekUv;
@JSONField(serialize = false)
private Long weekProductClickUv;
@JSONField(serialize = false)
private Long weekAddCartUv;
}
......@@ -21,19 +21,19 @@ public class CalculateUtils {
public static Double calculateRatioFactor(Double ratio, Integer count) {
Double rank = 1.0;
if (count > 1 && count < 10) {
rank = 1.2;
rank = 1.02;
} else if (count >= 10 && count < 20) {
rank = 1.4;
rank = 1.05;
} else if (count >= 20 && count < 50) {
rank = 1.6;
rank = 1.08;
} else if (count >= 50 && count < 100) {
rank = 1.8;
rank = 1.1;
} else if (count >= 100 && count < 200) {
rank = 2.0;
rank = 1.2;
} else if (count >= 200 && count < 500) {
rank = 2.2;
rank = 1.3;
} else if (count >= 500) {
rank = 2.5;
rank = 1.5;
}
//根据搜索转化率,转换为热度因子
return Math.log10(Math.sqrt(ratio + 10)) * rank;
......
......@@ -23,13 +23,38 @@ import java.util.List;
public class TestCode {
public static void main(String[] args) throws Exception {
List<String> esLines = FileUtils.readLines(new File("C:\\Users\\secoo\\Desktop\\suggest-index-20220720144919.json"));
EsClient esClient = EsClient.buildEsClient("http://127.0.0.1:9200", "", "");
int count = 0;
List<EsObject> esList = new ArrayList<>();
for (String esLine : esLines) {
EsSuggestKeywordInfo esSuggestKeywordInfo = JSON.parseObject(esLine, EsSuggestKeywordInfo.class);
if (esSuggestKeywordInfo != null && StringUtils.isNotBlank(esSuggestKeywordInfo.getKeyword())) {
count++;
esList.add(new EsObject(StringUtils.md5(esSuggestKeywordInfo.getKeyword()), esSuggestKeywordInfo));
}
if (count == 1000) {
esClient.batch("search_suggest_index", "search_suggest_type", esList);
count = 0;
esList = new ArrayList<>();
}
}
if (esList.size() > 0) {
esClient.batch("search_suggest_index", "search_suggest_type", esList);
}
esClient.close();
}
public static void main7(String[] args) throws Exception {
System.out.println(StringUtils.dbc2Sbc("模糊字母"));
System.out.println(PinYinUtils.convertToSimplifiedChinese("模糊字母"));
System.out.println(StringUtils.dbc2Sbc("模糊字母"));
System.out.println(PinYinUtils.convertToSimplifiedChinese("模糊字母"));
}
public static void main(String[] args) throws Exception {
public static void main6(String[] args) throws Exception {
List<String> esLines = FileUtils.readLines(new File("d:\\suggest-es.json"));
List<String> newLines = FileUtils.readLines(new File("d:\\suggest-index-keyword-20220209142219.txt"));
......@@ -50,7 +75,6 @@ public class TestCode {
}
public static void main5(String[] args) throws Exception {
EsClient esClient = EsClient.buildEsClient("http://yunhead.siku.cn", "search", "search5z0NvEn1D");
BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment