AQL Query Limits

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

AQL Query Limits

mgherman
Hi,

I am using AQL to query our artifactory repository (v3.6.0), and am attempting to limit the query results via ".limit()".

When using without a limit, there is a result set of 2 records, using limit, I have to set to .limit(7) before I see both records.

The unlimited query I am using:
items.find(
    {
	"$and":
	[
        	{"@build.name":{"$eq":"productX_build"}},
        	{"@sd_status.env_ver":{"$match":"*STG*"}}
	]
    }
).include("name", "repo", "path", "property.*")

And its results:
{
  "results" : [ {
    "repo" : "VendorX-shop-devel",
    "path" : "com/VendorX/productX/SNAPSHOT",
    "name" : "commission-core-129001-22.war",
    "properties" : [ {
      "key" : "build.name",
      "value" : "productX_build"
    }, {
      "key" : "build.number",
      "value" : "22.1"
    }, {
      "key" : "env.GO_PIPELINE_COUNTER",
      "value" : "${GO_PIPELINE_COUNTER}"
    }, {
      "key" : "env.GO_STAGE_COUNTER",
      "value" : "${GO_STAGE_COUNTER}"
    }, {
      "key" : "gocd.count",
      "value" : "${COUNT}"
    }, {
      "key" : "sd_status.env_ver",
      "value" : "QA,STG"
    } ]
  }, {
    "repo" : "VendorX-shop-devel",
    "path" : "com/VendorX/productX/SNAPSHOT",
    "name" : "doctrine-migrations-129001-22.tgz",
    "properties" : [ {
      "key" : "build.name",
      "value" : "productX_build"
    }, {
      "key" : "build.number",
      "value" : "22.1"
    }, {
      "key" : "env.GO_PIPELINE_COUNTER",
      "value" : "${GO_PIPELINE_COUNTER}"
    }, {
      "key" : "env.GO_STAGE_COUNTER",
      "value" : "${GO_STAGE_COUNTER}"
    }, {
      "key" : "gocd.count",
      "value" : "${COUNT}"
    }, {
      "key" : "sd_status.env_ver",
      "value" : "QA,STG"
    } ]
  } ],
  "range" : {
    "start_pos" : 0,
    "end_pos" : 2,
    "limit" : 1000
  }
}

Appending a sort and limit...
Query:
items.find(
    {
        "$and":
        [
                {"@build.name":{"$eq":"nemus_build"}},
                {"@sd_status.env_ver":{"$match":"*STG*"}}
        ]
    }
).include("name", "repo", "path", "property.*").sort({"$desc":["name"]}).limit(5)

The results:
{
  "results" : [ {
    "repo" : "VendorX-shop-devel",
    "path" : "com/VendorX/productX/SNAPSHOT",
    "name" : "doctrine-migrations-129001-22.tgz",
    "properties" : [ {
      "key" : "sd_status.env_ver",
      "value" : "QA,STG"
    }, {
      "key" : "gocd.count",
      "value" : "${COUNT}"
    }, {
      "key" : "env.GO_STAGE_COUNTER",
      "value" : "${GO_STAGE_COUNTER}"
    }, {
      "key" : "env.GO_PIPELINE_COUNTER",
      "value" : "${GO_PIPELINE_COUNTER}"
    }, {
      "key" : "build.number",
      "value" : "22.1"
    } ]
  } ],
  "range" : {
    "start_pos" : 0,
    "end_pos" : 1,
    "limit" : 5
  }
}
And now looking at the results, it appears to have not returned some of the properties that were set in the initial query.

Any hints, pointers to what I am missing etc would be greatly appreciated.