| 1 |
import { RedisCommandArgument } from '@redis/client/dist/lib/commands'; |
| 2 |
import { transformTuplesReply } from '@redis/client/dist/lib/commands/generic-transformers'; |
| 3 |
|
| 4 |
export function transformArguments(index: string): Array<string> { |
| 5 |
return ['FT.INFO', index]; |
| 6 |
} |
| 7 |
|
| 8 |
type InfoRawReply = [ |
| 9 |
'index_name', |
| 10 |
RedisCommandArgument, |
| 11 |
'index_options', |
| 12 |
Array<RedisCommandArgument>, |
| 13 |
'index_definition', |
| 14 |
Array<RedisCommandArgument>, |
| 15 |
'attributes', |
| 16 |
Array<Array<RedisCommandArgument>>, |
| 17 |
'num_docs', |
| 18 |
RedisCommandArgument, |
| 19 |
'max_doc_id', |
| 20 |
RedisCommandArgument, |
| 21 |
'num_terms', |
| 22 |
RedisCommandArgument, |
| 23 |
'num_records', |
| 24 |
RedisCommandArgument, |
| 25 |
'inverted_sz_mb', |
| 26 |
RedisCommandArgument, |
| 27 |
'vector_index_sz_mb', |
| 28 |
RedisCommandArgument, |
| 29 |
'total_inverted_index_blocks', |
| 30 |
RedisCommandArgument, |
| 31 |
'offset_vectors_sz_mb', |
| 32 |
RedisCommandArgument, |
| 33 |
'doc_table_size_mb', |
| 34 |
RedisCommandArgument, |
| 35 |
'sortable_values_size_mb', |
| 36 |
RedisCommandArgument, |
| 37 |
'key_table_size_mb', |
| 38 |
RedisCommandArgument, |
| 39 |
'records_per_doc_avg', |
| 40 |
RedisCommandArgument, |
| 41 |
'bytes_per_record_avg', |
| 42 |
RedisCommandArgument, |
| 43 |
'offsets_per_term_avg', |
| 44 |
RedisCommandArgument, |
| 45 |
'offset_bits_per_record_avg', |
| 46 |
RedisCommandArgument, |
| 47 |
'hash_indexing_failures', |
| 48 |
RedisCommandArgument, |
| 49 |
'indexing', |
| 50 |
RedisCommandArgument, |
| 51 |
'percent_indexed', |
| 52 |
RedisCommandArgument, |
| 53 |
'gc_stats', |
| 54 |
[ |
| 55 |
'bytes_collected', |
| 56 |
RedisCommandArgument, |
| 57 |
'total_ms_run', |
| 58 |
RedisCommandArgument, |
| 59 |
'total_cycles', |
| 60 |
RedisCommandArgument, |
| 61 |
'average_cycle_time_ms', |
| 62 |
RedisCommandArgument, |
| 63 |
'last_run_time_ms', |
| 64 |
RedisCommandArgument, |
| 65 |
'gc_numeric_trees_missed', |
| 66 |
RedisCommandArgument, |
| 67 |
'gc_blocks_denied', |
| 68 |
RedisCommandArgument |
| 69 |
], |
| 70 |
'cursor_stats', |
| 71 |
[ |
| 72 |
'global_idle', |
| 73 |
number, |
| 74 |
'global_total', |
| 75 |
number, |
| 76 |
'index_capacity', |
| 77 |
number, |
| 78 |
'index_total', |
| 79 |
number |
| 80 |
], |
| 81 |
'stopwords_list'?, |
| 82 |
Array<RedisCommandArgument>? |
| 83 |
]; |
| 84 |
|
| 85 |
interface InfoReply { |
| 86 |
indexName: RedisCommandArgument; |
| 87 |
indexOptions: Array<RedisCommandArgument>; |
| 88 |
indexDefinition: Record<string, RedisCommandArgument>; |
| 89 |
attributes: Array<Record<string, RedisCommandArgument>>; |
| 90 |
numDocs: RedisCommandArgument; |
| 91 |
maxDocId: RedisCommandArgument; |
| 92 |
numTerms: RedisCommandArgument; |
| 93 |
numRecords: RedisCommandArgument; |
| 94 |
invertedSzMb: RedisCommandArgument; |
| 95 |
vectorIndexSzMb: RedisCommandArgument; |
| 96 |
totalInvertedIndexBlocks: RedisCommandArgument; |
| 97 |
offsetVectorsSzMb: RedisCommandArgument; |
| 98 |
docTableSizeMb: RedisCommandArgument; |
| 99 |
sortableValuesSizeMb: RedisCommandArgument; |
| 100 |
keyTableSizeMb: RedisCommandArgument; |
| 101 |
recordsPerDocAvg: RedisCommandArgument; |
| 102 |
bytesPerRecordAvg: RedisCommandArgument; |
| 103 |
offsetsPerTermAvg: RedisCommandArgument; |
| 104 |
offsetBitsPerRecordAvg: RedisCommandArgument; |
| 105 |
hashIndexingFailures: RedisCommandArgument; |
| 106 |
indexing: RedisCommandArgument; |
| 107 |
percentIndexed: RedisCommandArgument; |
| 108 |
gcStats: { |
| 109 |
bytesCollected: RedisCommandArgument; |
| 110 |
totalMsRun: RedisCommandArgument; |
| 111 |
totalCycles: RedisCommandArgument; |
| 112 |
averageCycleTimeMs: RedisCommandArgument; |
| 113 |
lastRunTimeMs: RedisCommandArgument; |
| 114 |
gcNumericTreesMissed: RedisCommandArgument; |
| 115 |
gcBlocksDenied: RedisCommandArgument; |
| 116 |
}; |
| 117 |
cursorStats: { |
| 118 |
globalIdle: number; |
| 119 |
globalTotal: number; |
| 120 |
indexCapacity: number; |
| 121 |
idnexTotal: number; |
| 122 |
}; |
| 123 |
stopWords: Array<RedisCommandArgument> | undefined; |
| 124 |
} |
| 125 |
|
| 126 |
export function transformReply(rawReply: InfoRawReply): InfoReply { |
| 127 |
return { |
| 128 |
indexName: rawReply[1], |
| 129 |
indexOptions: rawReply[3], |
| 130 |
indexDefinition: transformTuplesReply(rawReply[5]), |
| 131 |
attributes: rawReply[7].map(attribute => transformTuplesReply(attribute)), |
| 132 |
numDocs: rawReply[9], |
| 133 |
maxDocId: rawReply[11], |
| 134 |
numTerms: rawReply[13], |
| 135 |
numRecords: rawReply[15], |
| 136 |
invertedSzMb: rawReply[17], |
| 137 |
vectorIndexSzMb: rawReply[19], |
| 138 |
totalInvertedIndexBlocks: rawReply[21], |
| 139 |
offsetVectorsSzMb: rawReply[23], |
| 140 |
docTableSizeMb: rawReply[25], |
| 141 |
sortableValuesSizeMb: rawReply[27], |
| 142 |
keyTableSizeMb: rawReply[29], |
| 143 |
recordsPerDocAvg: rawReply[31], |
| 144 |
bytesPerRecordAvg: rawReply[33], |
| 145 |
offsetsPerTermAvg: rawReply[35], |
| 146 |
offsetBitsPerRecordAvg: rawReply[37], |
| 147 |
hashIndexingFailures: rawReply[39], |
| 148 |
indexing: rawReply[41], |
| 149 |
percentIndexed: rawReply[43], |
| 150 |
gcStats: { |
| 151 |
bytesCollected: rawReply[45][1], |
| 152 |
totalMsRun: rawReply[45][3], |
| 153 |
totalCycles: rawReply[45][5], |
| 154 |
averageCycleTimeMs: rawReply[45][7], |
| 155 |
lastRunTimeMs: rawReply[45][9], |
| 156 |
gcNumericTreesMissed: rawReply[45][11], |
| 157 |
gcBlocksDenied: rawReply[45][13] |
| 158 |
}, |
| 159 |
cursorStats: { |
| 160 |
globalIdle: rawReply[47][1], |
| 161 |
globalTotal: rawReply[47][3], |
| 162 |
indexCapacity: rawReply[47][5], |
| 163 |
idnexTotal: rawReply[47][7] |
| 164 |
}, |
| 165 |
stopWords: rawReply[49] |
| 166 |
}; |
| 167 |
} |