Commit 474d2adc authored by 赵威's avatar 赵威

add second tags

parent 3ff83a9c
......@@ -54,15 +54,20 @@ object Main {
stream.map { user =>
val projects = user.projects.toList
val secondDemands = user.secondDemands.toList
val secondPositions = user.secondPositions.toList
val secondSolutions = user.secondSolutions.toList
val cityId = user.cityId
val deviceId = user.deviceId
println(deviceId)
// println(projects.mkString(" "))
val diaryReq = ES.generateDiaryRequest(projects, secondDemands, cityId, 300)
val tractateReq = ES.generateTractateRequest(projects, secondDemands, 300)
val answerReq = ES.generateAnswerRequest(projects, secondDemands, 100)
val serviceDiaryReq = ES.generateServiceDiaryRequest(projects, secondDemands, cityId, 100)
val diaryReq =
ES.generateDiaryRequest(projects, secondDemands, secondPositions, secondSolutions, cityId, 300)
val tractateReq =
ES.generateTractateRequest(projects, secondDemands, secondPositions, secondSolutions, 300)
val answerReq = ES.generateAnswerRequest(projects, secondDemands, secondPositions, secondSolutions, 100)
val serviceDiaryReq =
ES.generateServiceDiaryRequest(projects, secondDemands, secondPositions, secondSolutions, cityId, 100)
Redis.save(ES.request(diaryReq), deviceId, "diary")
Redis.save(ES.request(tractateReq), deviceId, "tractate")
......
......@@ -107,6 +107,8 @@ object ES {
def generateDiaryRequest(
projects: List[String],
secondDemands: List[String],
secondPositions: List[String],
secondSolutions: List[String],
cityId: Int = -1,
size: Int = 300
): SearchRequest = {
......@@ -126,6 +128,16 @@ object ES {
shouldListBuffer += TermsQuery("second_demands", secondDemands)
}
if (secondSolutions.size > 0) {
scoreListBuffer += WeightScore(30).filter(termsQuery("second_solutions", secondSolutions))
shouldListBuffer += TermsQuery("second_solutions", secondSolutions)
}
if (secondPositions.size > 0) {
scoreListBuffer += WeightScore(20).filter(termsQuery("second_positions", secondPositions))
shouldListBuffer += TermsQuery("second_positions", secondPositions)
}
val res = search("gm-dbmw-diary-read")
.query {
functionScoreQuery()
......@@ -170,6 +182,8 @@ object ES {
def generateTractateRequest(
projects: List[String],
secondDemands: List[String],
secondPositions: List[String],
secondSolutions: List[String],
size: Int = 300
): SearchRequest = {
val includes = List("id", "tags_v3")
......@@ -188,6 +202,16 @@ object ES {
shouldListBuffer += TermsQuery("second_demands", secondDemands)
}
if (secondSolutions.size > 0) {
scoreListBuffer += WeightScore(30).filter(termsQuery("second_solutions", secondSolutions))
shouldListBuffer += TermsQuery("second_solutions", secondSolutions)
}
if (secondPositions.size > 0) {
scoreListBuffer += WeightScore(20).filter(termsQuery("second_positions", secondPositions))
shouldListBuffer += TermsQuery("second_positions", secondPositions)
}
val res = search("gm-dbmw-tractate-read")
.query {
functionScoreQuery()
......@@ -218,6 +242,8 @@ object ES {
def generateAnswerRequest(
projects: List[String],
secondDemands: List[String],
secondPositions: List[String],
secondSolutions: List[String],
size: Int = 100
): SearchRequest = {
val includes = List("id", "tags_v3")
......@@ -236,6 +262,16 @@ object ES {
shouldListBuffer += TermsQuery("second_demands", secondDemands)
}
if (secondSolutions.size > 0) {
scoreListBuffer += WeightScore(30).filter(termsQuery("second_solutions", secondSolutions))
shouldListBuffer += TermsQuery("second_solutions", secondSolutions)
}
if (secondPositions.size > 0) {
scoreListBuffer += WeightScore(20).filter(termsQuery("second_positions", secondPositions))
shouldListBuffer += TermsQuery("second_positions", secondPositions)
}
val res = search("gm-dbmw-answer-read")
.query {
functionScoreQuery()
......@@ -270,6 +306,8 @@ object ES {
def generateServiceDiaryRequest(
projects: List[String],
secondDemands: List[String],
secondPositions: List[String],
secondSolutions: List[String],
cityId: Int = -1,
size: Int = 100
): SearchRequest = {
......@@ -283,6 +321,14 @@ object ES {
shouldListBuffer += TermsQuery("second_demands", secondDemands)
}
if (secondPositions.size > 0) {
shouldListBuffer += TermsQuery("second_positions", secondPositions)
}
if (secondSolutions.size > 0) {
shouldListBuffer += TermsQuery("second_solutions", secondSolutions)
}
val res = search("gm-dbmw-diary-read")
.query {
functionScoreQuery(
......
......@@ -7,6 +7,8 @@ case class UserInfo(
eventCn: String,
cityId: Int,
secondDemands: Array[String],
secondPositions: Array[String],
secondSolutions: Array[String],
projects: Array[String],
businessTags: Array[String]
)
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