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

add second tags

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