Как создать правило оповещения с помощью запроса OR через / manage / alert / actions / rules - PullRequest
0 голосов
/ 02 января 2019

Я пытаюсь создать правило предупреждения, которое запускается, когда в базу данных вставляется документ, содержащий 2 элемента с определенным значением.Я могу сделать это с api alert в qconsole, но по какой-то причине это не работает при попытке опубликовать правило через / manage / alert / rules api.

{
    "name": "email-notification-rule",
    "description": "Send email notification",
    "user-name": "admin",
    "query": {
        "orQuery": {
            "queries": [
                {
                    "elementValueQuery": {
                        "element": "LogType",
                        "text": "ERROR"
                    }
                },
                {
                    "elementValueQuery": {
                        "element": "Notification",
                        "text": "TRUE"
                    }
                }
            ]
        }
    },
    "action-name": "send-email-notification",
    "option": []
}

Ожидаемый результат:

<?xml  version="1.0" encoding="UTF-8"?>
<alert:rule id="8448603273660731662"     xmlns:alert="http://marklogic.com/xdmp/alert">
    <alert:name>email-notification-rule</alert:name>
    <alert:description>Send email notification</alert:description>
    <alert:user-id>7071164303237443533</alert:user-id>
    <alert:query>
        <cts:or-query xmlns:cts="http://marklogic.com/cts">
            <cts:element-value-query>
                <cts:element>Notification</cts:element>
                <cts:text xml:lang="en">TRUE</cts:text>
            </cts:element-value-query>
            <cts:element-value-query>
                <cts:element>LogType</cts:element>
                <cts:text xml:lang="en">ERROR</cts:text>
            </cts:element-value-query>
        </cts:or-query>
    </alert:query>
    <alert:action-name>send-email-notification</alert:action-name>
    <alert:external-security-id>0</alert:external-security-id>
    <alert:user-name>
    </alert:user-name>
    <alert:options>
    </alert:options>
</alert:rule>

но фактически созданный документ правила:

<alert:rule id="8448603273660731662"     xmlns:alert="http://marklogic.com/xdmp/alert">
    <alert:name>email-notification-rule</alert:name>
    <alert:description>Send email notification</alert:description>
    <alert:user-id>7071164303237443533</alert:user-id>
    <alert:query>
        <cts:or-query xmlns:cts="http://marklogic.com/cts">
            <cts:element-value-query>
                <cts:element>Notification</cts:element>
                <cts:text xml:lang="en">TRUE</cts:text>
            </cts:element-value-query>
        </cts:or-query>
    </alert:query>
    <alert:action-name>send-email-notification</alert:action-name>
    <alert:external-security-id>0</alert:external-security-id>
    <alert:user-name>
    </alert:user-name>
    <alert:options>
    </alert:options>
</alert:rule>

По какой-то причине MarkLogic вставляет в базу данных только последний запрос из orQuery ..

Для меня этопохоже на ошибку, но, возможно, я неправильно пишу тело json.

...