[−][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:
JBIDXSTRString index for JSON string values.JBIDXISTRCase insensitive string index for JSON string values.JBIDXNUMIndex for JSON number values.JBIDXARRToken index for JSON arrays and string values.
-
One JSON field can have several indexes for different types.
-
Available index operations:
JBIDXDROPDrop index of specified type. - Eg: flag = JBIDXDROP | JBIDXNUM (Drop number index)JBIDXDROPALLDrop index for all types.JBIDXREBLDRebuild index of specified type.JBIDXOPOptimize 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