Marklogic: DLS-INVALIDVERSION - versioning

when trying to access older versions of my managed XML files, it gives me something like:
DLS-INVALIDVERSION: (err:FOER0000) /company/1448220.xml has no version number 3
in /MarkLogic/dls.xqy, at 1403:6, ...
Indeed, the file of version 1, 2, 3 within /company/1448220_xml_versions does not exist (in this case lets assume version 4 is the most recent).
When updating a document using dls (Document Management) functions, I run the following tasks:
Check whether the document is managed or not
When its not managed, set to manage using dls:document-manage($uri, fn:false()) inside of an eval statement
Update the document using dls:document-checkout-update-checkin($uri, $new-doc, "Document
update", fn:true()) inside of an eval statement
So far so good.
When tying to get a specific version of a document:
dls:document-version($document-uri, xs:unsignedInt($version))
==> When using $version := 4 it gives me a valid document (which in turn is the most recent version)
==> When using $version := 1 it just gives me an error, indicating that the document of version 1 doesn't exist.
What I am doing wrong?
I am using MarkLogic 6.

You probably haven't set a retention policy using dls:retention-rule-insert, and the default retention rules retain nothing (which means that MarkLogic deletes all older versions of a given document each time you store a new version of it). See the "Defining a retention policy" section in the MarkLogic Application Developer's Guide, here.

Related

How to order the app engine versions in gcloud based on LAST_DEPLOYED

I would like to show the latest version generated in app engine, I have this:
gcloud app versions list --sort-by=~VERSION
when executing the command it shows me:
I would like to sort by string based on the name of the version and that the output is only the latest version.
I pray you can help me.
Greetings.
The gcloud app versions list command accepts a --limit option which may be handy to obtain what you want:
--limit=LIMIT
Maximum number of resources to list. The default is unlimited. This
flag interacts with other flags that are applied in this order:
--flatten, --sort-by, --filter, --limit.
So you could get a single entry using --limit=1
To get the latest as opposed to the oldest you may need to reverse the sorting order, which is possible using the ~ prefix:
--sort-by=[FIELD,…]
Comma-separated list of resource field key names to sort by. The
default order is ascending. Prefix a field with ``~´´ for descending
order on that field.
Note that you may need to get rid of (some of) the versions that use different name formats than the default, timestamp-based one (like the a2 and v2 ones showing in your current list) for the scheme to work.
Side note: you may want to stop some of those versions - they all appear running now, possibly unnecessarily chewing resources and driving up costs.
This will give you the version ID of the last deployment
gcloud app versions list --sort-by="~last_deployed_time" --limit=1 --format="value(id)"
If you want to sort by version string use this one
gcloud app versions list --sort-by="~id" --limit=1 --format="value(id)"

Selecting direct children with Postgres ltree using Elixir

I'm trying to select any children that are a single level below with ltree.
For example, if I had Car.Ford, the query would grab any child with a path such as Car.Ford.Fiesta, Car.Ford.Fusion, Car.Ford.Mustang.
How can I build this query using ltree, if possible, specifically using Elixir?
Right now I'm using
from c in query, where: fragment("path <# ?", c.path)
But it returns all entries with the path in it.
Figured this out.
The documentation on Postgres states that the {} in an lquery limits the number of labels it will match, the documentation from the developers clarifies that this is actually to limit the number of levels to search.
'My.Example.*{1}'
That will match anything one level below a path starting with My.Example

Managing redis keys using wildcards in Cakephp

I use cakephp 2 and redis.
How do I remove all keys from cache by the wildcards mask?
For example I want to remove all by mask "prefix_element_group1*"
About clearGroup I know.
But it only increments the group value to simulate deletion of all keys under a group old values will remain in storage until they expire.
At least how to get a list of keys using a mask? similar to "keys *" in redis-cli
Your problem isn't specific to CakePHP. You can delete arbitrary keys with wildcard support using Lua scripts with eval. Here's a PHP example:
$deleteScript = 'return redis.call("DEL", unpack(redis.call("keys", ARGV[1])))';
$redis = getRedisConnection(); // whatever CakePHP provides
$redis->eval($deleteScript, 0, "keyPattern:*");
Obviously the exact syntax will differ based on your particular Redis library, but hopefully this should give you the right idea.

XQuery update for document with versions

I am trying to update value of some property in xDB using XQuery, here is my transaction:
let $source := doc('/historicalresource')/HistoricalResourceData[id/#UUID = '0361513e-30fa-45e4-a73a-d05870b8a284']
let $res := $source/ResourceProperty[#PropertyName="cpu|limit"]/#PropertyValue
let $change := '21572'
return replace value of node $res with $change
After running this query I receive such error:
com.xhive.error.XhiveException: VERSION_ACCESS_DENIED: This document
is versioned and can only be changed through a versioning operation
Indeed in my case historicalresource is a folder which may contain more than one document and all they have a version, like: v1.1 ,v1.2, etc..
How can I update the value of last version using xquery?
How should I modify my query to be able to update desired value ?
Finally, I have found the answer to my question, therefore adding it here:
There is no way to update xDB file using xQuery as it is version based system and xQuery cannot create a new version, but it could be done manually or automatically by some coding language (for example: java):
Manually - by editing existing version in xDB, in that case a new version will be automatically created after saving any change to existing version of the file.
Automatically - by checking out the file, making the change and submitting the change as a new version.
For versioned documents (on which XhiveLibraryChildIf.makeVersionable() was called), this is indeed the case: you have to check out the document first, then run the update query on the checked out copy, and finally check the new version in. For non-versioned documents, however, you can apply the update query directly.

Error on creating database in phppgadmin

I have PostgreSQL 9.2.0. On clicking create database it shows following error:
SQL error:
ERROR: column "spclocation" does not exist
LINE 1: ...pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocatio...
^
In statement:
SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation,
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid) AS spccomment
FROM pg_catalog.pg_tablespace WHERE spcname NOT LIKE $$pg\_%$$ ORDER BY spcname
Quick Fix: (worked with my Version (5.0.3) / pg 9.2.3 )
change to /classes/database
copy Postgres84.php to Postgres92.php
open Connection.php
add a line case '9.2': return 'Postgres92'; break; at the // Detect version and choose appropriate database driver switch.
open Postgres.php and copy functions getTablespaces + getTablespace
open Postgres92.php and paste the functions into the class
replace ", spclocation," with ", pg_tablespace_location(oid) as
spclocation," in both functions.
in Postgres92.php change class name to Postgres92
I updated to Mountain Lion on my Mac Mini Server on the evening of 12/12/2012 which runs PostgreSQL 9.2.1. I had the same problem when I found this question. When I did a search about this problem I found the following bug tracker on the matter.
http://sourceforge.net/tracker/?func=detail&aid=3570272&group_id=37132&atid=418980
One of the comments suggests to download the developer branch from github to get around this from https://github.com/phppgadmin/phppgadmin/zipball/master. I did this and copied the to /Library/Server/Web/Data/Sites/Default and renamed the folder. I modified $conf['servers'][0]['host'] to 127.0.0.1 in /conf/config.inc.php. I think I had to copy config.inc.php-dist. I have been successful in creating databases. As of 12/12 they had not released a stable version for 9.2. Hopefully they will soon.
In short: table pg_tablespace does not have that column in 9.2.
It seems that information should be obtained from other means now, as mentioned in the mailing list.
Also notice how in the official phpPgAdmin page, the latest PostgreSQL supported version is 9.0.
And for 'Quick Fix', add one more step after (2):
Change the class name in Postgres92.php from Postgres84 to Postgres92.

Resources