0
votes

I wanted to fetch the document which have the particular element attribute value.

So, I tried the cts:element-attribute-value-query but I didn't get any result. But the same element attribute value, I am able to get using cts:element-attribute-range-query.

Here the sample snippet used.

let $s-query := cts:element-attribute-range-query(xs:QName("tit:title"),xs:QName("name"),"=",
"SampleTitle",
("collation=http://marklogic.com/collation/codepoint"))


let $s-query := cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"),
"SampleTitle",
())

return cts:search(fn:doc(),($s-query))

The problem with range-query is it needs the range index. I have hundreds of DB's in multiple hosts. I need to create range indexes on each DB.

What could be the problem with attribute-value-query?

1
Cannot reproduce with MarkLogic database 8.0-3. Can you elaborate? - grtjn

1 Answers

2
votes

I found the issue with a couple of research.

Actually the result document is a french language document. It has the structure as follows. This is a sample.

<doc xml:lang="fr:CA" xmlns:tit="title">
    <tit:title name="SampleTitle"/>
</doc>

The cts:element-attribute-value-query is a language dependent query. To get the french language results, then language needs to be mentioned in the option as follows.

cts:element-attribute-value-query(xs:QName("tit:title"),xs:QName("name"), "SampleTitle",("lang=fr"))

But cts:element-attribute-range-query don't require the language option.

Thanks for the effort.