FOR a in Asset COLLECT attr = a.attribute1 INTO g RETURN { value: attr, count: length(g) }
[ { "value": "test-attr1-1", "count": 2000000 }, { "value": "test-attr1-2", "count": 2000000 }, { "value": "test-attr1-3", "count": 3000000 }]
LET docs = (FOR a IN Asset
FILTER a.name like 'test-asset-%'
SORT a.name
RETURN a)
LET attribute1 = (
FOR a in docs
COLLECT attr = a.attribute1 INTO g
RETURN { value: attr, count: length(g[*])}
)
LET attribute2 = (
FOR a in docs
COLLECT attr = a.attribute2 INTO g
RETURN { value: attr, count: length(g[*])}
)
LET attribute3 = (
FOR a in docs
COLLECT attr = a.attribute3 INTO g
RETURN { value: attr, count: length(g[*])}
)
LET attribute4 = (
FOR a in docs
COLLECT attr = a.attribute4 INTO g
RETURN { value: attr, count: length(g[*])}
)
RETURN {
counts: (RETURN {
total: LENGTH(docs),
offset: 2,
to: 4,
facets: {
attribute1: {
from: 0,
to: 5,
total: LENGTH(attribute1)
},
attribute2: {
from: 5,
to: 10,
total: LENGTH(attribute2)
},
attribute3: {
from: 0,
to: 1000,
total: LENGTH(attribute3)
},
attribute4: {
from: 0,
to: 1000,
total: LENGTH(attribute4)
}
}
}),
items: (FOR a IN docs LIMIT 2, 4 RETURN {id: a._id, name: a.name}),
facets: {
attribute1: (FOR a in attribute1 SORT a.count LIMIT 0, 5 return a),
attribute2: (FOR a in attribute2 SORT a.value LIMIT 5, 10 return a),
attribute3: (FOR a in attribute3 LIMIT 0, 1000 return a),
attribute4: (FOR a in attribute4 SORT a.count, a.value LIMIT 0, 1000 return a)
}
}
FOR a in Asset COLLECT attr = a.attribute1 INTO g RETURN { value: attr, count: length(g) }
FOR a in Asset COLLECT value = a.attribute1 WITH COUNT INTO length
RETURN { value, length }
LET docs = (FOR a IN Asset
RETURN a)LET attribute1 = ( FOR a in docs
COLLECT attr = a.attribute1 WITH COUNT INTO length RETURN { value: attr, count: length}
)LET attribute2 = ( FOR a in docs
COLLECT attr = a.attribute2 WITH COUNT INTO length RETURN { value: attr, count: length}
)LET attribute3 = ( FOR a in docs
COLLECT attr = a.attribute3 WITH COUNT INTO length RETURN { value: attr, count: length}
)LET attribute4 = ( FOR a in docs
COLLECT attr = a.attribute4 WITH COUNT INTO length RETURN { value: attr, count: length}
LET docs = (FOR a IN Asset
FILTER a.name like 'test-asset-%'
SORT a.name
RETURN a)
RETURN {
counts: (RETURN {
total: LENGTH(docs),
offset: 0,
to: 5
}),
items: (FOR a IN docs LIMIT 0, 5 RETURN a)
}
LET docs = (FOR a IN Asset
FILTER a.name like 'test-asset-%'
RETURN a)
LET attributeX = (
FOR a in docs
COLLECT attr = a.attributeX WITH COUNT INTO length
RETURN { value: attr, count: length}
)
RETURN {
counts: (RETURN {
total: LENGTH(docs),
offset: 0,
to: -1,
facets: {
attributeX: {
from: 0,
to: 1000,
total: LENGTH(attributeX)
}
}
}),
facets: {
attributeX: (FOR a in attributeX LIMIT 0, 1000 return a)
}
}