The view object of the JavaScript API
View objects represent ArangoSearch Views and provide access to information and methods for executing View-related operations
The JavaScript API returns view objects when you use the following methods
of the db
object from the @arangodb
module:
db._createView(...)
db._views()
db._view(...)
Methods
view.name()
Returns the name of the View.
Examples
Get View name:
var view = db._view("demoView");
view.name();
Show output
demoView
view.type()
Returns the type of the View.
Examples
Get View type:
var view = db._view("demoView");
view.type();
Show output
arangosearch
view.properties(new-properties [, partialUpdate])
view.properties()
Returns the properties of the View. The format of the result is specific to each of the supported View Types.
Examples
Get View properties:
var view = db._view("demoView");
view.properties();
Show output
{
"writebufferSizeMax" : 33554432,
"writebufferIdle" : 64,
"storedValues" : [ ],
"consolidationPolicy" : {
"type" : "tier",
"segmentsBytesFloor" : 2097152,
"segmentsBytesMax" : 5368709120,
"segmentsMax" : 10,
"segmentsMin" : 1,
"minScore" : 0
},
"writebufferActive" : 0,
"links" : {
},
"commitIntervalMsec" : 1000,
"consolidationIntervalMsec" : 1000,
"optimizeTopK" : [ ],
"cleanupIntervalStep" : 2,
"primarySort" : [ ],
"primarySortCompression" : "lz4"
}
view.properties(new-properties, partialUpdate)
Modifies the properties of the view
. The format of the result is specific to
each of the supported View Types.
partialUpdate
is an optional Boolean parameter (true
by default) that
determines how the new-properties
object is merged with current View properties
(adds or updates new-properties
properties to current if true
replaces all
properties if false
).
For the available properties of the supported View types, see:
Examples
Modify arangosearch
View properties:
var view = db._view("example");
view.properties();
// set cleanupIntervalStep to 12
view.properties({cleanupIntervalStep: 12});
// add a link
view.properties({links: {demo: {}}})
// remove a link
view.properties({links: {demo: null}})
Show output
{
"writebufferSizeMax" : 33554432,
"writebufferIdle" : 64,
"storedValues" : [ ],
"consolidationPolicy" : {
"type" : "tier",
"segmentsBytesFloor" : 2097152,
"segmentsBytesMax" : 5368709120,
"segmentsMax" : 10,
"segmentsMin" : 1,
"minScore" : 0
},
"writebufferActive" : 0,
"links" : {
},
"commitIntervalMsec" : 1000,
"consolidationIntervalMsec" : 1000,
"optimizeTopK" : [ ],
"cleanupIntervalStep" : 2,
"primarySort" : [ ],
"primarySortCompression" : "lz4"
}
{
"cleanupIntervalStep" : 12,
"commitIntervalMsec" : 1000,
"consolidationIntervalMsec" : 1000,
"consolidationPolicy" : {
"type" : "tier",
"segmentsBytesFloor" : 2097152,
"segmentsBytesMax" : 5368709120,
"segmentsMax" : 10,
"segmentsMin" : 1,
"minScore" : 0
},
"optimizeTopK" : [ ],
"primarySort" : [ ],
"primarySortCompression" : "lz4",
"storedValues" : [ ],
"writebufferActive" : 0,
"writebufferIdle" : 64,
"writebufferSizeMax" : 33554432,
"links" : {
}
}
{
"cleanupIntervalStep" : 12,
"commitIntervalMsec" : 1000,
"consolidationIntervalMsec" : 1000,
"consolidationPolicy" : {
"type" : "tier",
"segmentsBytesFloor" : 2097152,
"segmentsBytesMax" : 5368709120,
"segmentsMax" : 10,
"segmentsMin" : 1,
"minScore" : 0
},
"optimizeTopK" : [ ],
"primarySort" : [ ],
"primarySortCompression" : "lz4",
"storedValues" : [ ],
"writebufferActive" : 0,
"writebufferIdle" : 64,
"writebufferSizeMax" : 33554432,
"links" : {
"demo" : {
"analyzers" : [
"identity"
],
"fields" : {
},
"includeAllFields" : false,
"storeValues" : "none",
"trackListPositions" : false
}
}
}
{
"cleanupIntervalStep" : 12,
"commitIntervalMsec" : 1000,
"consolidationIntervalMsec" : 1000,
"consolidationPolicy" : {
"type" : "tier",
"segmentsBytesFloor" : 2097152,
"segmentsBytesMax" : 5368709120,
"segmentsMax" : 10,
"segmentsMin" : 1,
"minScore" : 0
},
"optimizeTopK" : [ ],
"primarySort" : [ ],
"primarySortCompression" : "lz4",
"storedValues" : [ ],
"writebufferActive" : 0,
"writebufferIdle" : 64,
"writebufferSizeMax" : 33554432,
"links" : {
}
}
Add and remove inverted indexes from a search-alias
View:
var view = db._view("example");
view.properties();
view.properties({ indexes: [
{ collection: "coll", index: "inv1", operation: "del" },
{ collection: "coll", index: "inv3" }
] });
Show output
{
"indexes" : [
{
"collection" : "coll",
"index" : "inv1"
},
{
"collection" : "coll",
"index" : "inv2"
}
]
}
{
"indexes" : [
{
"collection" : "coll",
"index" : "inv2"
},
{
"collection" : "coll",
"index" : "inv3"
}
]
}
view.rename(new-name)
Renames a view using the new-name
. The new-name
must not already be used by
a different view or collection in the same database. new-name
must also be a
valid view name. For information about the naming constraints for Views, see
View names.
If renaming fails for any reason, an error is thrown.
Examples
var view = db._createView("example", "arangosearch");
view.name();
view.rename("exampleRenamed");
view.name();
Show output
example
exampleRenamed
view.drop()
Drops a View and all its data.
Examples
Drop a View:
var view = db._createView("example", "arangosearch");
// or
var view = db._view("example");
view.drop();
db._view("example");
Show output
null