简体   繁体   中英

Marklogic: Skipping xml document while performing queries

I'm running XQuery in MarkLogic. The number of xml documents in the database is 764. The number of documents that the query returns results for is 382, which is the half of the number of documents available in the database. I've tried a simple code to make sure that this is actually happening:

declare namespace rec="http://apa.org/pimain";

for $record at $index in /rec:Record 
return $index

The last $index I'm getting is 382. I've made sure that the number of instances in the database is 764 . Any ideas?

For data loading I've used Information Studio. These are the ingestion settings 摄取

The permissions 权限

The user is nobody

This is a re-posting of your question-

Marklogic: How to know the number of records returned by an xquery?

You have provided a little more information, I guess, so that's good.

Given that you get 382 for fn:count(/rec:Record) it sounds like you either have a problem with namespaces, document structure, or permissions.

Permissions can be ruled out by knowing if you're executing the XQuery as a user with admin privs or some other user. If you're running it as another user, make sure the documents are all loaded with read privileges for that user. xdmp:document-get-permissions($uri) can help you...see docs.marklogic.com for more help.

How many records are you seeing when you click on the Query Console "Explore" button? That can give you some insights.

You expect 764 documents in the database, so what is returned from fn:count(fn:doc()) ? This will return the count of documents in the database. If you get anything other than the 764 you expect, then you need to provide more information about how you're loading records because you don't have the expected number of documents.

Another snippet to try, especially if you have other documents in the database, would be to try fn:count(/*:Record) . This returns the count of any document with <Record> parent element, regardless of namespace. If you get 764, you've got half your documents loaded with a different namespace than what you declared, but have the same <Record> parent element.

You show screenshots from the (deprecated) Information Studio Flows. It was a convenient little tool that kept track of which files were loaded when. It did so using the (also deprecated) ticket system . Such documents would be put in a collection that matched the ticket id, and would also get document properties with ticket information. You probably have 382 documents, and 382 properties fragments. Add those and you get the 764 count you observe, but you really just have 382 documents in your database.

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM