elasticsearch - SonarQube使用不正确的(?)ElasticSearch查询来获取ScmAccountToUser

标签 elasticsearch sonarqube sonarqube5.3 sonarqube-ops

我在具有MSSQL后端的Windows上运行SonarQube 5.3。

创建新的Issue时,SonarQube会查询其ElasticSearch用户索引以获取提交该问题的行的“git blame”信息的作者登录信息。

在/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IssueAssigner.java中发生以下情况:

=>“git blame”信息返回受影响的行的作者,在我的示例中(匿名):

steve smith@ca5553f7-9c36-c34d-916b-b330600317e9

=>在ScmAccountToUser中查找此值,它懒惰地查询ElasticSearch索引“用户”。我添加了一些调试输出以打印ES查询,即:
{
  "size": 3,
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "bool": {
          "must": {
            "term": {
              "active": true
            }
          },
          "should": [
            {
              "term": {
                "login": "steve smith@ca5553f7-9c36-c34d-916b-b330600317e9"
              }
            },
            {
              "term": {
                "email": "steve smith@ca5553f7-9c36-c34d-916b-b330600317e9"
              }
            },
            {
              "term": {
                "scmAccounts": "steve smith@ca5553f7-9c36-c34d-916b-b330600317e9"
              }
            }
          ]
        }
      }
    }
  }
}

该查询返回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 smith@ca5553f7-9c36-c34d-916b-b330600317e9
",
            "steve.smith@ca5553f7-9c36-c34d-916b-b330600317e9
"
          ],
          "email": "steve.smith@globodex.ch",
          "updatedAt": 1450088380632
        }
      },
      // snip
    ]
  }
}

当前,此问题阻止了SonarQube实例自动分配很多问题。由于某些自动分配先前已成功完成,因此我正在弄清楚何时/如何发生这种情况。

这是查询或数据中的错误吗?我可以以某种方式解决此问题吗?

最佳答案

原来,问题出在“scmAccounts”字段条目中的换行符。

通过在SonarQube UI中手动重新添加SCM帐户,这些字段已更新为

"scmAccounts": 
[ -
            "steve smith@ca5553f7-9c36-c34d-916b-b330600317e9",
            "steve.smith@ca5553f7-9c36-c34d-916b-b330600317e9"
],

,此后查询成功并且问题分配成功。

由于我是通过备份SQL INSERT脚本在SQL Server上手动还原表“users”的,所以换行首先进入了字段。

关于elasticsearch - SonarQube使用不正确的(?)ElasticSearch查询来获取ScmAccountToUser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36791856/

相关文章:

perl - 如何在MetaCPAN上进行滚动搜索?

python - ElasticSearch/Solr-产品站点的同义词?

java - sonarqube代码分析报告生成时如何触发邮件?

r - 如何使用 SonarQube API 正确地将报告上传到 SonarQube

java - 在项目上执行 sonarQube 的问题由 : java. lang.UnsupportedClassVersionError: org/sonarsource/scanner/maven/SonarQubeMojo 引起

elasticsearch - 查看Elasticsearch的 “sense”中的列标题

database - Elasticsearch数据库:Elasticsearch在哪里存储数据?

java - 为什么 SonarQube 在类序列化时给出 transient /私有(private)错误?

java - SonarQube Gradle 插件警告 : "Class not found: org.joda.convert"

Jenkins 无法使用带有自签名证书的 HTTPS (HTTP + SSL) 连接到 SonarQube 服务器