[−][src]Function ejdb_sys::ejdbsetindex
pub unsafe extern "C" fn ejdbsetindex(
coll: *mut EJCOLL,
ipath: *const c_char,
flags: c_int
) -> bool
Set index for JSON field in EJDB collection.
-
Available index types:
JBIDXSTR
String index for JSON string values.JBIDXISTR
Case insensitive string index for JSON string values.JBIDXNUM
Index for JSON number values.JBIDXARR
Token index for JSON arrays and string values.
-
One JSON field can have several indexes for different types.
-
Available index operations:
JBIDXDROP
Drop index of specified type. - Eg: flag = JBIDXDROP | JBIDXNUM (Drop number index)JBIDXDROPALL
Drop index for all types.JBIDXREBLD
Rebuild index of specified type.JBIDXOP
Optimize index of specified type. (Optimize the B+ tree index file)
Examples:
- Set index for JSON path addressbook.number
for strings and numbers:
ejdbsetindex(ccoll, "album.number", JBIDXSTR | JBIDXNUM)
- Set index for array:
ejdbsetindex(ccoll, "album.tags", JBIDXARR)
- Rebuild previous index:
ejdbsetindex(ccoll, "album.tags", JBIDXARR | JBIDXREBLD)
Many index examples can be found in testejdb/t2.c
test case.
@param coll Collection handle. @param ipath BSON field path. @param flags Index flags. @return