TJ Tang
TJ Tang

Reputation: 921

extract-document-data in search options erroring

I attempted to follow the example in the search developers guide for configuring record elements to be extracted in the search results.

<options xmlns="http://marklogic.com/appservices/search">
    <extract-document-data>
        <extract-path xmlns:pdbe="http://schemas.abbvienet.com/people-db/envelope" xmlns:pdbm="http://schemas.abbvienet.com/people-db/model">/pdbe:person-envelope/pdbm:person/pdbm:account</extract-path>
    </extract-document-data>
</options>

With those options, I get the error.

[1.0-ml] XDMP-UNBPRFX: (err:XPST0081) Prefix pdbe has no namespace binding

Even when I try the example from the example from the guide, verbatim, I get the error as well (that is as long as I am getting hits back and it is trying to extract, if there are no hits, then it does not error).

Am I doing something wrong?

UPDATE

If I add the namespaces with the /config/namespaces REST endpoint first, and then search using the REST API, then I get the extracted values. But, I am unable to test using search:search in the query console. If I remove the config/namespaces, then I see the same error in the query console as directly from the REST endpoint.

Upvotes: 3

Views: 146

Answers (1)

Dave Cassel
Dave Cassel

Reputation: 8422

The documented example in the Syntax Summary section has a typo (I've alerted the docs team): the xmlns attribute is misspelled "xmnls". That would account for the error when using that verbatim example.

Pasting in your example as-is, it looks like it works fine (MarkLogic 8.0-5.2). Perhaps you corrected the "xmnls" error while posting the question?

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

search:search("hello sample-property-constraint:boo",
  <options xmlns="http://marklogic.com/appservices/search">
    <extract-document-data>
      <extract-path 
          xmlns:pdbe="http://schemas.abbvienet.com/people-db/envelope" 
          xmlns:pdbm="http://schemas.abbvienet.com/people-db/model">
        /pdbe:person-envelope/pdbm:person/pdbm:account
      </extract-path>
    </extract-document-data>
  </options>)

Upvotes: 3

Related Questions