4

i want to export selected documents from MarkLogic using MLCP based on xpath match.

mlcp export -host localhost -port 8061 -username admin -password admin -mode local -output_file_path shiv -database shiv -output_type archive -document_selector '/companymetadata/companyCode=shiv'

here i want to export all the documents which matches /companymetadata/companyCode=shiv this condition but i am getting following error

18/06/06 16:50:57 INFO contentpump.ContentPump: Job name: local_712261411_1
18/06/06 16:50:57 ERROR mapreduce.MarkLogicInputFormat: com.marklogic.xcc.exceptions.XQueryException: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting Rpar_
 [Session: user=admin, cb=shiv [ContentSource: user=admin, cb=shiv [provider: address=localhost/127.0.0.1:8061, pool=1/64]]]
 [Client: XCC/9.0-3, Server: XDBC/8.0-5.5]
in /eval, on line 4
expr:
18/06/06 16:50:57 ERROR mapreduce.MarkLogicInputFormat: Query: xquery version "1.0-ml";
import module namespace hadoop = "http://marklogic.com/xdmp/hadoop" at "/MarkLogic/hadoop.xqy";
xdmp:host-name(xdmp:host()),
hadoop:get-splits('', ''collection()/companymetadata/companyCode=shiv'','()'),
"REDACT",0,let $repf := fn:function-lookup(xs:QName('hadoop:get-splits-with-replica'),0)
return if (exists($repf)) then $repf() else ()
,0,"AUDIT",
let $f :=
    fn:function-lookup(xs:QName('xdmp:group-get-audit-event-type-enabled'), 2)
return
    if (not(exists($f)))
    then ()
    else
        let $group-id := xdmp:group()
        let $enabled-event := $f($group-id,("mlcp-copy-export-start", "mlcp-copy-export-finish"))
        let $mlcp-start-enabled :=
                if ($enabled-event[1]) then "mlcp-copy-export-start" else ()
        let $mlcp-finish-enabled :=
                if ($enabled-event[2]) then "mlcp-copy-export-finish" else ()
        return ($mlcp-start-enabled, $mlcp-finish-enabled)
18/06/06 16:50:57 ERROR contentpump.LocalJobRunner: Error getting input splits:
18/06/06 16:50:57 ERROR contentpump.LocalJobRunner: com.marklogic.xcc.exceptions.XQueryException: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting Rpar_
 [Session: user=admin, cb=shiv [ContentSource: user=admin, cb=shiv [provider: address=localhost/127.0.0.1:8061, pool=1/64]]]
 [Client: XCC/9.0-3, Server: XDBC/8.0-5.5]
in /eval, on line 4
expr:

Please help me to solve above error also guide me to use xpath with MLCP.

DevNinja
  • 1,459
  • 7
  • 10

1 Answers1

2

There's an example of xpath use at http://docs.marklogic.com/guide/mlcp/export#id_89322 so it looks possible. I would recommend generally to work up your xpath so it works in query console first, then try in mlcp. Maybe you want something like

/companymetadata[companyCode = 'shiv']
asusu
  • 321
  • 1
  • 5
  • Thx @asusu for reply... I am getting same error `/companymetadata[companyCode = 'shiv']` – DevNinja Jun 06 '18 at 13:06
  • 1
    Try putting all command-line arguments in an options_file, which each argument on a separate line. You are facing some issues with extra single quotes, and the whitespace in above xpath might be bothering too. – grtjn Jun 06 '18 at 15:29
  • Thx grtjn... I tried `mlcp export -host localhost -username admin -password admin -port 8061 -database shiv -options_file test.txt` and `test.txt` is having `-document_selector /companymetadata[companyCode=shiv] -mode local -output_file_path shiv1 -output_type archive` this options now mlcp command is executing without any error but now it is not exporting records as well. I am getting output as ` ESTIMATED_INPUT_RECORDS: 2 INPUT_RECORDS: 0 OUTPUT_RECORDS: 0` – DevNinja Jun 07 '18 at 06:02
  • 1
    You keep using invalid xpath expressions. "/companymetadata[companyCode=shiv]" is not valid. You need quotes around the "shiv" value. You really need to play with the expression in Query Console until you get one that is both syntactically correct and yields the desired results. Mlcp will simply take what you give it and use it with fn:collection, thus: fn:collection/companymetadata[companyCode="shiv"]. – kcoleman Jun 07 '18 at 15:06
  • Thx @kcoleman for your valuable comment, now it is working with small modification. – DevNinja Jun 08 '18 at 09:36