MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Schema_AddFullTextIndex

Function Schema_AddFullTextIndex

src/schema/schema.c:68–115  ·  view source on GitHub ↗

add a full-text index to schema

Source from the content-addressed store, hash-verified

66
67// add a full-text index to schema
68static int Schema_AddFullTextIndex
69(
70 Index *idx, // [input/output] index to create
71 Schema *s, // schema holding the index
72 IndexField *field // field to index
73) {
74 ASSERT(s != NULL);
75 ASSERT(idx != NULL);
76 ASSERT(field != NULL);
77
78 // see if index already exists
79 Index _idx = NULL;
80
81 //--------------------------------------------------------------------------
82 // determine which index to populate
83 //--------------------------------------------------------------------------
84
85 // if pending-index exists, reuse it
86 // if active-index exists, clone it and use clone
87 // otherwise (first index) create a new index
88 Index active = ACTIVE_FULLTEXT_IDX(s);
89 Index pending = PENDING_FULLTEXT_IDX(s);
90 Index altered = (pending != NULL) ? pending : active;
91
92 if(altered != NULL) {
93 // make sure attribute isn't already indexed
94 if(Index_ContainsAttribute(altered, field->id)) {
95 // field already indexed, quick return
96 IndexField_Free(field);
97 return INDEX_FAIL;
98 }
99 }
100
101 _idx = pending;
102 if(pending == NULL) {
103 if(active != NULL) {
104 _idx = Index_Clone(active);
105 } else {
106 _idx = Index_New(s->name, s->id, IDX_FULLTEXT, GETYPE_NODE);
107 }
108 }
109 PENDING_FULLTEXT_IDX(s) = _idx; // set pending full-text index
110
111 Index_AddField(_idx, field);
112
113 *idx = _idx;
114 return INDEX_OK;
115}
116
117static int _Schema_RemoveExactMatchIndex
118(

Callers 1

Schema_AddIndexFunction · 0.85

Calls 5

Index_ContainsAttributeFunction · 0.85
IndexField_FreeFunction · 0.85
Index_CloneFunction · 0.85
Index_NewFunction · 0.85
Index_AddFieldFunction · 0.85

Tested by

no test coverage detected