gjwilson21
gjwilson21

Reputation: 123

Is it possible to index a document property and add it as a column in a SQL view?

We are replicating some data from a relational database to marklogic and would like to verify if the data is replicated properly. We wanted to create a view to compare the data.

Unfortunately, we don't store the last updated timestamp element in the document, but it is available as a document property. Is there a way to index the properties of documents and add that as a column for a view?

Upvotes: 2

Views: 131

Answers (3)

gjwilson21
gjwilson21

Reputation: 123

Got this answer from Marklogic support.

Unfortunately, views do not provide the ability join the document and property fragments. So it is not possible to add document properties as a column to the view.

Upvotes: 1

mblakele
mblakele

Reputation: 7842

Properties are elements, so you can create a range index on prop:last-modified just like any other element. And you could include it in a view.

However it's not clear from the docs whether that will actually work in a SQL view, and my experiment was unsuccessful. You might try asking MarkLogic support to get a definitive answer, and file an RFE if the answer is no.

Upvotes: 0

wst
wst

Reputation: 11771

This might be too disruptive, but you could create a script to update the documents to copy the property timestamp to an element or attribute value and - depending on how many documents need updating - run it in batches on the Task Server using xdmp:spawn().

Upvotes: 1

Related Questions