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

Function Index_IndexGraphEntity

src/index/index.c:141–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141RSDoc *Index_IndexGraphEntity
142(
143 Index idx,
144 const GraphEntity *e,
145 const void *key,
146 size_t key_len,
147 uint *doc_field_count
148) {
149 ASSERT(idx != NULL);
150 ASSERT(e != NULL);
151 ASSERT(key != NULL);
152 ASSERT(doc_field_count != NULL);
153 ASSERT(key_len > 0);
154
155 double score = 1; // default score
156 IndexField *field = NULL; // current indexed field
157 SIValue *v = NULL; // current indexed value
158 EntityID id = ENTITY_GET_ID(e);
159 uint field_count = array_len(idx->fields);
160
161 *doc_field_count = 0;
162
163 // list of none indexable fields
164 uint none_indexable_fields_count = 0; // number of none indexed fields
165 const char *none_indexable_fields[field_count]; // none indexed fields
166
167 // create an empty document
168 RSDoc *doc = RediSearch_CreateDocument2(key, key_len, NULL, score,
169 idx->language);
170
171 // add document field for each indexed property
172 if(idx->type == IDX_FULLTEXT) {
173 for(uint i = 0; i < field_count; i++) {
174 field = idx->fields + i;
175 const char *field_name = field->name;
176 v = GraphEntity_GetProperty(e, field->id);
177 if(v == ATTRIBUTE_NOTFOUND) continue;
178
179 SIType t = SI_TYPE(*v);
180
181 // value must be of type string
182 if(t == T_STRING) {
183 *doc_field_count += 1;
184 RediSearch_DocumentAddFieldString(doc, field_name, v->stringval,
185 strlen(v->stringval), RSFLDTYPE_FULLTEXT);
186 }
187 }
188 } else {
189 for(uint i = 0; i < field_count; i++) {
190 field = idx->fields + i;
191 const char *field_name = field->name;
192 v = GraphEntity_GetProperty(e, field->id);
193 if(v == ATTRIBUTE_NOTFOUND) continue;
194
195 SIType t = SI_TYPE(*v);
196
197 *doc_field_count += 1;
198 if(t == T_STRING) {

Callers 2

Index_IndexNodeFunction · 0.85
Index_IndexEdgeFunction · 0.85

Calls 6

array_lenFunction · 0.85
GraphEntity_GetPropertyFunction · 0.85
Point_latFunction · 0.85
Point_lonFunction · 0.85
rm_mallocFunction · 0.85
rm_freeFunction · 0.85

Tested by

no test coverage detected