responsible for creating the index structure only! e.g. fields, stopwords, language
| 98 | // responsible for creating the index structure only! |
| 99 | // e.g. fields, stopwords, language |
| 100 | void Index_ConstructStructure |
| 101 | ( |
| 102 | Index idx |
| 103 | ) { |
| 104 | ASSERT(idx != NULL); |
| 105 | ASSERT(idx->rsIdx == NULL); |
| 106 | |
| 107 | RSIndex *rsIdx = NULL; |
| 108 | RSIndexOptions *idx_options = RediSearch_CreateIndexOptions(); |
| 109 | RediSearch_IndexOptionsSetLanguage(idx_options, idx->language); |
| 110 | // TODO: Remove this comment when https://github.com/RediSearch/RediSearch/issues/1100 is closed |
| 111 | // RediSearch_IndexOptionsSetGetValueCallback(idx_options, _getNodeAttribute, gc); |
| 112 | |
| 113 | #ifndef MEMCHECK |
| 114 | // enable GC, every 30 seconds gc will check if there's garbage |
| 115 | // if there are over 100 docs to remove GC will perform clean up |
| 116 | RediSearch_IndexOptionsSetGCPolicy(idx_options, GC_POLICY_FORK); |
| 117 | #endif |
| 118 | |
| 119 | if(idx->stopwords) { |
| 120 | RediSearch_IndexOptionsSetStopwords(idx_options, |
| 121 | (const char**)idx->stopwords, array_len(idx->stopwords)); |
| 122 | } else if(idx->type == IDX_EXACT_MATCH) { |
| 123 | RediSearch_IndexOptionsSetStopwords(idx_options, NULL, 0); |
| 124 | } |
| 125 | |
| 126 | rsIdx = RediSearch_CreateIndex(idx->label, idx_options); |
| 127 | RediSearch_FreeIndexOptions(idx_options); |
| 128 | |
| 129 | // create indexed fields |
| 130 | if(idx->type == IDX_FULLTEXT) { |
| 131 | _Index_ConstructFullTextStructure(idx, rsIdx); |
| 132 | } else { |
| 133 | _Index_ConstructExactMatchStructure(idx, rsIdx); |
| 134 | } |
| 135 | |
| 136 | // set RediSearch index |
| 137 | ASSERT(idx->rsIdx == NULL); |
| 138 | idx->rsIdx = rsIdx; |
| 139 | } |
| 140 | |
| 141 | RSDoc *Index_IndexGraphEntity |
| 142 | ( |
no test coverage detected