运行聚合查询的数据存储建立在Elasticsearch ⁇ (当前版本1.7.x)之上。Elasticsearch 提供实时搜索和聚合功能,分析 API 在上面形成一个薄薄的安全增强层。例子中使用了弹性搜索查询和聚合语言。
-
查询 JSON 的筛选字段中使用的语言在 ⁇ 弹性搜索查询 DSL ⁇ 文档中说明。
-
查询 JSON 的聚合字段中使用的语言在 ⁇ Elasticsearch 聚合 ⁇ 文档中有全面描述。
Indexes
不同类型的数据生活在不同的索引中。例如,工作数据生活在jobPart索引中,而成本数据生活在成本索引中。可以通过在聚合 API 端点 URL 中指定索引来指定所需的数据。
父子文件
工作的部分信息存储在 Elasticsearch 数据库中两个不同的文档中。这些文件是父子关系。例如,有关工作项目的信息存在于父文档中,而有关工作本身的信息存在于子文档中。根据所需的信息,聚合在数据父子聚合之前或之后,但数据聚合本身应存在于所有查询中。
共同数据
分析
{ "id": string, "createdBy": <User>, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "innerId": number, "name": string, "tags": string[], "trashed": boolean, "trashedBy": <User>, "type": string }
分配
{ "name": string, "linguist": <User>, "vendor": <Vendor> }
提交页面
{ "id": string, "createdBy": <User>, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "name": string, "tags": string[], "trashed": boolean, "urlId": string }
买方
{ "id": string, "name": string }
客户
{ "id": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "externalId": string, "name": string, "tags": string[], "trashed": boolean, }
CostCenter
{ "id": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "name": string, "tags": string[], "trashed": boolean, }
域
{ "id": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "name": string, "tags": string[], "trashed": boolean }
Job
{ "id": string, "createdBy": <User>, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "extension": string, "fileName": string, "groupCount": number, "innerId":"1", "languagePair": string, "lastModified":日期, "localePair": string, "sourceLanguage": string, "sourceLocale": string, "tags": string[], "targetLanguage": string, "targetLocale": string", "taskId": string, "trashed": boolean, "trashedBy": <User>, "uid": string }
JobPart
{ "id":"19", "assignedTo": <Assignment>, "beginIndex": number, "buyer": <Buyer>, "createdBy": <User>, "dateCreated":日期, "dateDue":日期, "endIndex": number, "groupCount": number, "innerId": string, "lastModified":日期, "level": number, "status": string, "tags": [], "uid": string, "workflowStep": <WorkflowStep> }
MtEngine
{ "id": string, "deleted": boolean, "default_: 布尔值, "includeTags": boolean, "name": string, "tags": string[], "type": string, }
NetRateScheme
{ "id": string, "createdBy": <User>, "dateCreated":日期, "dateDeleted":日期, "default_": boolean, "deleted": boolean, "externalId": string, "name": string, "tags": string[], }
PriceList
{ "id": string, "createdBy": <User>, "currency": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "default_": boolean, "deleted": boolean, "name": string, "tags": string[], "trashed": boolean, "unit": string }
Project
{ "id": string, "buyer": <Buyer>, "client": <Client>, "costCenter": <CostCenter>, "createdBy": <User>, "dateCreated":日期, "dateDeleted":日期, "dateDue":日期, "dateTrashed":日期, "deleted": boolean, "domain": <Domain>, "innerId": number, "languagePairs": string[], "localePairs": string[], "mtEngine": <MtEngine>, "name": string, "note": string, "owner": <User>, "sourceLanguage": string, "sourceLocale": string, "status": string, "subDomain": <SubDomain>, "tags": string[], "targetLanguages": string[], "targetLocales": string[], "trashed": boolean, "trashedBy": <User>, "uid": string, "vendor": <Vendor> }
报价
{ "id": string, "createdBy: <User>, "currency": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "innerId": string, "name": string, "status": string, "tags": string[], "trashed": boolean, "trashedBy": <User>, "unit": string }
服务
{ "id": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "name": string, "publicName": string, "tags": string[], "trashed": boolean, "type": string }
SubDomain
{ "id": string, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "name": string, "tags": string[], "trashed": boolean }
用户
{ "id": number, "active": boolean, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "email": string, "firstName": string, "fullName": string, "innerId": number, "jobTitle": string, "lastName": string, "locale": string, "note": string, "role": string, "tags": string[], "timeZone": string, "trashed": boolean, "userName": string }
供应商
{ "id": string, "candidate": boolean, "dateCreated":日期, "dateDeleted":日期, "dateTrashed":日期, "deleted": boolean, "tags": string[], "token": string, "trashed": boolean }
WorkflowStep
{ "id": string, "abbreviation": string, "dateDeleted":日期, "dateTrashed":日期, "name": string, "order": number, "tags": string[], "trashed": boolean }
分析指数
数据聚合
"data": { "children": { "type": "analysisType" } }
父文档
{ "automationWidget": <AutomationWidget>, "project": <Project>, "service": <Service> }
子文档
{ "analysis": <Analysis>, "jobPart": <JobPart>, "job": <Job>, "netRateScheme": <NetRateScheme>, "priority": number, "data": { "mt": { "match0": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match100": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match50": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match75": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match85": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match95": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number } }, "repetitions": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "tm": { "match0": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match100": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match101": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match50": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match75": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match85": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number }, "match95": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number } }, "total": { "characters": number, "pages": number, "percent": number, "segments": number, "words": number } } }
API 索引
数据聚合
"data": { "children": { "type": "apiType" } }
父文档
{ "user": <User> }
子文档
{ "request": { "date":日期, "host": string, "ipv4": string, "ipv6": string, "location": string, "method": string }, "response": { "date":日期, "duration": number, "status": number }, "api": { "action": string, "asynch": boolean, "type": string, "uri": string, "ver": string } }
成本指数
数据聚合
"data": { "children": { "type": "costsType" } }
父文档
{ "automationWidget": <AutomationWidget>, "project": <Project>, "service": <Service> }
子文档
{ "analysis": <Analysis>, "job": <Job>, "jobPart": <JobPart>, "netRateScheme": <NetRateScheme>, "priceList": <PriceList>, "quote": <Quote>, "workflowStep": <WorkflowStep>, "priority": number, "data": { "mt": { "match0": number, "match100": number, "match50": number, "match75": number, "match85": number, "match95": number }, "repetitions": number, "tm": { "match0": number, "match100": number, "match101": number, "match50": number, "match75": number, "match85": number, "match95": number }, "total": number } }
jobPart 索引
数据聚合
"data": { "children": { "type": "jobPartType" } }
父文档
{ "automationWidget": <AutomationWidget>, "project": <Project>, "service": <Service> }
子文档
{ "job": <Job>, "jobPart": <JobPart> "data": { "counts": { "chars": { "total": number, "confirmed": number, "notConfirmed": number, "locked": number, "notLocked": number, "confirmedAndLocked": number, "notConfirmedAndLocked": number, "completed": number, "notCompleted": number }, "groups": { "total": number }, "segments": { "total": number, "confirmed": number, "notConfirmed": number, "locked": number, "notLocked": number, "confirmedAndLocked": number, "notConfirmedAndLocked": number, "completed": number, "notCompleted": number, "mt": { "postEdited": number, "relevant": number, "notRelevant": number }, "qa": { "checked": number, "notChecked": number } }, "words": { "total": number, "confirmed": number, "notConfirmed": number, "locked": number, "notLocked": number, "confirmedAndLocked": number, "notConfirmedAndLocked": number, "completed": number, "notCompleted": number }, "qa": { "warnings": number, "ignoredWarnings": number, "notIgnoredWarnings": number } } }
-
HTTP 请求在 Postman 中运行。
-
通过项目项目经理或管理员员个人资料文件登录,并使用登录 API 获得登录令牌。
-
向
API/v3/ Analytics/jobPart?token=<your_login_token>发布
请求
工作总数
查询
{ "aggregations": { "data": { "children": { "type": "jobPartType" } } } }
响应
{ "hits": { "total":359 }, "aggregations": { "data": { "doc_count":14417 } } }
在聚合字段下,数据聚合响应了 doc_count 字段中显示的 14,417 个匹配文档。
原文/源语单词总数
查询
{ "aggregations": { "data": { "children": { "type": "jobPartType" }, "aggs": { "wordCount": { "sum": { "field": "data.volume.words" } } } } } }
响应
{ "hits": { "total":359 }, "aggregations": { "data": { "doc_count":14417, "wordCount": { "value":6893067 } } } }
原文/源语单词数除以译文语言的总数
查询
{ "aggregations": { "data": { "children": { "type": "jobPartType" }, "aggs": { "byTargetLanguage": { "terms": { "field": "job.targetLanguage", "size":3 }, "aggs": { "wordCount": { "sum": { "field": "data.volume.words" } } } } } } } }
响应
{ "hits": { "total":359 }, "aggregations": { "data": { "byTargetLanguage": { "doc_count_error_upper_bound":0, "sum_other_doc_count":10071, "buckets": [ { "doc_count":1835, "wordCount": { "value":702721 }, "key": "cs" }, { "doc_count":1491, "wordCount": { "value":2602529 }, "key": "de" }, { "doc_count":1020, "wordCount": { "value":92676 }, "key": "fi" } ] }, "doc_count":14417 } } }
存储实体显示在响应中。当要求 Analytics 模块按某个类别拆分数据时,结果将显示为存储的列表。每个存储包含一个定义该存储代表的数据(此处为译文语言)的键和一个仅适用于该部分数据集的值(其他聚合)。
工作总数除以项目状态
查询
{ "aggregations": { "projectStatus": { "terms": { "field": "project.status" }, "aggs": { "data": { "children": { "type": "jobPartType" } } } } } }
响应
{ "hits": { "total":359 }, "aggregations": { "projectStatus": { "doc_count_error_upper_bound":0, "sum_other_doc_count":0, "buckets": [ { "doc_count":326, "data": { "doc_count":14318 }, "key":“新的” }, { "doc_count":31, "data": { "doc_count":89 }, "key":“已完成” }, { "doc_count":1, "data": { "doc_count":4 }, "key":“已分配” }, { "doc_count":1, "data": { "doc_count":6 }, "key":"DECLINED_BY_VENDOR" } ] } } }
分析模块被告知在数据汇总之前按项目状态拆分数据。
来自新项目的工作总数
查询
{ "filter": { "term": { "project.status":“新的” } }, "aggregations": { "data": { "children": { "type": "jobPartType" } } } }
响应
{ "hits": { "total":326 }, "aggregations": { "data": { "doc_count":14318 } } }
筛选字段用于查询。这缩小了数据的范围,然后再进行汇总。