我在Windows上運行帶有MSSQL後端的SonarQube 5.3。SonarQube使用不正確的(?)ElasticSearch查詢來獲取ScmAccountToUser
當創建新問題時,SonarQube查詢其ElasticSearch用戶索引,以獲取呈現該問題的行的「git blame」信息的作者登錄。
下面在/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueAssigner.java發生:
=>的 「GIT中怪」 信息返回作者受影響的線路,在我的示例的(匿名):
steve [email protected]
=>此值在ScmAccountToUser,其懶惰地查詢ElasticSearch指數「用戶」擡頭。我添加了一些調試輸出來打印ES查詢,它是:
{
"size": 3,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": {
"term": {
"active": true
}
},
"should": [
{
"term": {
"login": "steve [email protected]"
}
},
{
"term": {
"email": "steve [email protected]"
}
},
{
"term": {
"scmAccounts": "steve [email protected]"
}
}
]
}
}
}
}
}
此查詢返回0個結果。
相反,當我列舉整個索引,我得到一擊一般應該匹配該用戶:
{ -
"took": 4,
"timed_out": false,
"_shards": { -
"total": 5,
"successful": 5,
"failed": 0
},
"hits": { -
"total": 39,
"max_score": 1,
"hits": [ -
{ -
// snip
},
// snip
{ -
"_index": "users",
"_type": "user",
"_id": "steve.smith",
"_score": 1,
"_source": { -
"createdAt": 1442988141642,
"name": "Steve Smith",
"active": true,
"login": "steve.smith",
"scmAccounts": [ -
"
",
"steve [email protected]
",
"[email protected]
"
],
"email": "[email protected]",
"updatedAt": 1450088380632
}
},
// snip
]
}
}
這個問題目前阻止我SonarQube例如從自動分配一個很大的問題。我正在確定何時/如何中斷,因爲某些自動分配功能先前已成功。
這是查詢中還是數據中的錯誤?我能以某種方式解決這個問題嗎?
scmAccounts字段的映射是什麼?如果它不是'not_analyzed'字符串字段,那就是原因。 – Val
映射做具體說明: // ... 「scmAccounts」:{ - 「索引」: 「not_analyzed」, 「類型」: 「串」 }, // ... 而不同來自其他領域,例如登錄: 「登錄」:{ - 「索引」: 「not_analyzed」, 「類型」: 「串」, 「字段」:{ - 「n元語法」:{ - 「search_analyzer」: 「search_ngrams」 , 「index_analyzer」: 「index_ngrams」, 「類型」: 「串」 }} } , 這是映射的配置錯誤呢?我已經完全恢復了索引,所以問題不斷出現。 – ThePadawan
根本原因似乎是scm賬戶中的空白。你確認嗎? –