0
votes

I have to search words in specific path and for that I have set the path range index in admin and tried the below code in query console but it is not working.

cts:search(fn:doc(),cts:path-range-query("/root/author/name","=","word"),"unfiltered")

I have tried with the relative path and absolute path but it is not working. It is not even giving error.

Please suggest.

1
Hallo @rit. Your question is hard to grasp. Can you provide a minimal reproducible example of your code? - Robert
Hi Robert, There is a task which can only be accomplish using path range index if any other ways please suggest. I have to search in path /root/author/name. For this I have firstly set the path range index in admin "author/name" and then I have tried the code : cts:search(fn:doc(),cts:path-range-query("author/name","=","word"),"unfiltered") which is not working. There is no result coming and if I tried the same code in marklogic v8 then it is working fine. Is there any option that need to be enabled? I am using the marklogic version 9.0-8.2. thanks, rit - user11347079
You are mixing up the xpath in your comment and your question: "/root/author/name" vs "author/name". Is that a typo or might that be the error? - Wagner Michael

1 Answers

0
votes

For me on v9.0-9, if I add a path-range-index for path author/name, type string, root collation, then a search of

cts:search(fn:doc(),cts:path-range-query("author/name","=","smith"),"unfiltered")

finds

<doc><author><name>smith</name></author></doc>

but doesn't find

<doc><author><name>zachary smith</name></author></doc>

However, if you are really searching for words, then a range index may not be what you need. Take a look at value queries at

https://help.marklogic.com/Knowledgebase/Article/View/476/0/understanding-search-value-queries

or fields

http://docs.marklogic.com/guide/admin/fields