marklogic-community / roxy

Deployment tool for MarkLogic applications. Also provides optional unit test and XQuery MVC structure
Other
87 stars 66 forks source link

How to use cts:element-attribute-value-query() efficiently #882

Closed AnujMLDev closed 6 years ago

AnujMLDev commented 6 years ago

Hi All,

I want to use cts:element-attribute-value-query(). In below is my Xquery

cts:search(fn:doc(), cts:and-query(( cts:element-attribute-value-query( xs:QName("note"), xs:QName("ID"), "980"), cts:element-attribute-value-query( xs:QName("note"), xs:QName("bn"), "true"))))

This is throwing an expanded tree cache full error as the database has millions of docs. And I want to run this query on every doc but the result of a query is very less. Any way to make it better?

TIA

dmcassel commented 6 years ago

Hi @AnujMLDev. Let me first note that this is a general MarkLogic search question, not anything to do with Roxy. As such, it would be better to ask it on Stack Overflow, where more people will see your question and others with a similar problem are more likely to benefit from an answer.

That said, you should be able to solve the problem with pagination. That is, instead of getting all results at once, get the first 10 (or 20 or 50 or 100) docs, do what you're going to with those, then make another call.

cts:search(fn:doc(), $and-query)[$start to $end]

If that approach doesn't work for you, then I encourage you to post a more detailed question (stating what you want to accomplish) on Stack Overflow. I think you would find it helpful to read through Fast Pagination and Unfiltered Searches, as well.