我正在协调MarkLogic中的文档,这些文档在26分钟的中完成,而不执行通配符代码片段(注释掉)。当我执行下面的代码时,协调时间将在更长的时间内完成,即1小时和50分钟。
这段代码片段是我翻译以下SQL代码的尝试:
DECLARE @GETPRODLOSS decimal(18,2)
IF @ASSETNUMBER = NULL
SET @GETPRODLOSS = NULL
ELSE
SELECT @GETPRODLOSS = CONVERT(decimal(18,2), SUM(GLU/100))
FROM AccountLedgerTable
WHERE GLDCT = 'MU' AND
GLSBLT = 'W' AND
LTRIM(SUBSTRING(GLASID,2,25)) LIKE concat('%',@assetNumber) AND
GLSBL LIKE concat('%',@workOrder)
GROUP BY GLANI
RETURN(@GETPRODLOSS)
END我不知道为什么要花那么长时间才能执行。下面是MarkLogic中相应的javascript代码片段:
function getAffectedProduction(assetNumber, workOrder) {
let accountLedger = cts.search(cts.andQuery([
cts.collectionQuery("JDEdwards"),
cts.collectionQuery("JDEAccountLedger"),
cts.elementWordQuery(fn.QName("http://www.example.com/ads/JDEdwards/document","GLDCT"), "MU"),
cts.elementWordQuery(fn.QName("http://www.example.com/ads/JDEdwards/document","GLSBLT"), 'W'),
cts.elementWordQuery(fn.QName("http://www.example.com/ads/JDEdwards/document","GLASID"), fn.concat("*", assetNumber), "wildcarded"),
cts.elementWordQuery(fn.QName("http://www.example.com/ads/JDEdwards/document","GLSBL"), fn.concat("*", workOrder), "wildcarded")
]))
let affectedProduction = new Number();
if(fn.count(accountLedger) <= 0) return "";
affectedProduction = 0;
let docXML = new String();
for (const item of accountLedger) {
affectedProduction += fn.number(`${fn.normalizeSpace(hl.elementText(item, "GLU"))}`);
}
return fn.string(fn.abs(affectedProduction/100));
}
注意:我已经为元素GLDCT、GLSBLT、GLASID、GLSBL设置了元素范围索引。
我的密码有什么问题吗?或者在使用通配符时需要打开管理界面设置?
发布于 2018-10-03 06:06:49
看看MarkLogic的建议的通配符索引设置。我还会将您的cts.search调用设置为在您遵循建议之后作为未过滤的方式运行。
https://stackoverflow.com/questions/52619366
复制相似问题