1

As my title says, I met some problem when I change the position for not-query, then I found that not-query does not work. It looks like it disappeared. I give an example as below.

cts:element-query(fn:QName("http://www.test/jeremy","doc"), 
    cts:and-query(
    (cts:or-query((cts:and-query(
        (cts:collection-query("xxxx"), 
            cts:or-query((
                cts:directory-query("/xxx/", "1"),
                cts:directory-query("/xxxx/", "1"), 
                cts:directory-query("/xxxxxx/", "1"), 
                cts:directory-query("/xx/x/", "1"),
                cts:directory-query("/xxxxx/", "1")), ()),
            cts:element-range-query(fn:QName("http://www.test/jeremy","apple"), "=", "xxxxxxx",("collation=http://marklogic.com/collation/codepoint"), 1), 
            cts:or-query(cts:element-value-query(fn:QName("http://www.test/jeremy","banana"), "SHANGHAI", ("lang=en"), 0), ())), ()),
            cts:not-query(cts:element-value-query(fn:QName("http://www.test/jeremy","orange"), "123456", ("lang=en"), 0), 0)), ()), 
    cts:not-query(cts:element-attribute-range-query(fn:QName("http://www.test/jeremy","groupid"), fn:QName("","isGood"), "=", "false", ("collation=http://marklogic.com/collation/codepoint"), 1), 0)
    ), 
    ()), 
())

Is there any god would help me with this. I am a new guy for marklogic, so I really need your help.

2 Answers 2

2

The thing that is wrong with your cts:not-query() is that you have two parameters being sent to that function. It accepts one.

For instance, this:

cts:not-query(
  cts:element-attribute-range-query(fn:QName("http://www.test/jeremy","groupid"), fn:QName("","isGood"), "=", "false", ("collation=http://marklogic.com/collation/codepoint"), 1),
  0
)

Should just be:

cts:not-query(
  cts:element-attribute-range-query(fn:QName("http://www.test/jeremy","groupid"), fn:QName("","isGood"), "=", "false", ("collation=http://marklogic.com/collation/codepoint"), 1)
)

In the cts:element-attribute-range-query you are sending 1 as the 6th parameter to indicate a weight.

It seems that maybe you were trying to set 0 on your cts:not-query either as a weight, or was just a mistake. Sometimes it is difficult to keep track of all the nested parenthesis, so formatting and/or let variables and combining can help make it easier to read.

If you had multiple queries that you wanted to negate, you would send in a sequence of queries to the cts:not-query(), and in order for it to be one parameter would need to wrap in parenthesis. For example:

cts:not-query( (cts:word-query("foo"), cts:word-query("bar")) )
Sign up to request clarification or add additional context in comments.

1 Comment

well, you are right, I should publish a question with a correct format
0

The not-query is invalid because it is not followed by a valid query. The not-query needs to be followed by a valid query in order for it to be valid.

cts:element-query(fn:QName("http://www.test/jeremy","doc"), 
cts:and-query(
    cts:collection-query("xxxx"), 
    cts:or-query(
        cts:directory-query("/xxx/", "1"),
        cts:directory-query("/xxxx/", "1"), 
        cts:directory-query("/xxxxxx/", "1"), 
        cts:directory-query("/xx/x/", "1"),
        cts:directory-query("/xxxxx/", "1")
    ),
    cts:element-range-query(fn:QName("http://www.test/jeremy","apple"), "=", "xxxxxxx",("collation=http://marklogic.com/collation/codepoint"), 1), 
    cts:element-value-query(fn:QName("http://www.test/jeremy","banana"), "SHANGHAI", ("lang=en"), 0),
    cts:not-query(cts:element-value-query(fn:QName("http://www.test/jeremy","orange"), "123456", ("lang=en"), 0), 0),
    cts:not-query(cts:element-attribute-range-query(fn:QName("http://www.test/jeremy","groupid"), fn:QName("","isGood"), "=", "false", ("collation=http://marklogic.com/collation/codepoint"), 1), 0)
), 
()

)

4 Comments

Thank you for your answer. Could you give me some document about your answer, because I wanna learn more about it. I would appreciate it if you do so :)
So , you mean that if I exchanged the position of cts:not-query(cts:element-value-query(fn:QN ...... and ` cts:element-value-query(fn:QName.....` , it would work right?
this smells like a ChatGPT answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.