Nic Gibson
Nic Gibson

Reputation: 7143

Marklogic faceted search and collations

I'm setting up a faceted search in MarkLogic. I have the following range indexes configured:

enter image description here

That is, I have two indexes. The first is on namespace http://www.corbas.co.uk/ns/presentations and local name keyword. The second has the local name level. The collation URI for both is http://marklogic.com/collation/en/S1.

When I try to search using the following I see errors related to collations:

xquery version "1.0-ml";


import module namespace search = "http://marklogic.com/appservices/search"
    at "/MarkLogic/appservices/search/search.xqy";

search:search("levels:Intermediate",
<options xmlns="http://marklogic.com/appservices/search">
  <return-results>true</return-results>
  <return-facets>true</return-facets>

  <constraint name="keywords"  facet="true">
    <range type="xs:string" collation="http://marklogic.com/collation/en/S1">
        <element ns="http://www.corbas.co.uk/ns/presentations" name="keyword"/>
    </range>
  </constraint>
  <constraint name="levels"  facet="true">
    <range type="xs:string" collation="http://marklogic.com/collation/en/S1">
        <element ns="http://www.corbas.co.uk/ns/presentations" name="level"/>
    </range>
  </constraint>

</options>)

I get the following error:

XDMP-ELEMRIDXNOTFOUND: cts:search(fn:collection(), 
cts:element-range query(fn:QName("http://www.corbas.co.uk/ns/presentations","level"), 
"=", "Intermediate", ("collation=http://marklogic.com/collation/en/S1"), 1), 
("score-logtfidf", "faceted", cts:score-order("descending")),
 xs:double("1"), ()) -- No string element range index for 
{http://www.corbas.co.uk/ns/presentations}level 
collation=http://marklogic.com/collation/en/S1

What am I doing wrong?

Upvotes: 1

Views: 173

Answers (3)

Dave Cassel
Dave Cassel

Reputation: 8422

It looks to me like your configuration is correct, which suggests to me that the problem is timing. Once you specify what indexes you want, MarkLogic gets to work creating them. If you run a query that requires those indexes before MarkLogic finishes creating them, you get this error. Depending on the amount of content you have, the creation process can be very quick or take hours.

To check the status, point your browser to the Admin UI (http://localhost:8001) and navigate to the configuration page for your database. Click on the Status tab and look for "Reindexing/Refragmenting State"—if MarkLogic is still reindexing, it will tell you so here and you'll get updates on its progress. (You can also get this information through the Management API.)

Upvotes: 1

Strange Message. If it even got that far, then it looks like your database default collation is changed. Does not answer the question. just strange.

Forst off, I would always add the collation to the constraint:

<search:range type="xs:string" facet="true" 
       collation="http://marklogic.com/collation/en/S1">

Second, I always troubleshoot range index issue from the query console: use cts:values() to verify that your indexes are in place and in the namespace and collation you expect. This removes other layers and verifies that the index is as you expect.

And another item: MarkLogic range indexes do not exist until content is indexed. Are you sure you have not turned off auto-index on the database and perhaps content is not indexed? That would give you an error.

Upvotes: 2

grtjn
grtjn

Reputation: 20414

To be honest, I would have expected a different error message. I would have expected MarkLogic to complain it couldn't find an index for root collation, because you have not added collation attributes on the range elements in the search options.

Maybe adding those will help.

HTH!

Upvotes: 1

Related Questions