|
4 | 4 | import static redis.clients.jedis.Protocol.Command.SCAN;
|
5 | 5 | import static redis.clients.jedis.Protocol.Keyword.TYPE;
|
6 | 6 |
|
| 7 | +import java.util.List; |
| 8 | +import java.util.Map; |
7 | 9 | import java.util.Set;
|
8 | 10 |
|
9 | 11 | import redis.clients.jedis.commands.ProtocolCommand;
|
10 | 12 | import redis.clients.jedis.params.ScanParams;
|
11 | 13 | import redis.clients.jedis.resps.ScanResult;
|
| 14 | +import redis.clients.jedis.search.IndexOptions; |
| 15 | +import redis.clients.jedis.search.Query; |
| 16 | +import redis.clients.jedis.search.Schema; |
| 17 | +import redis.clients.jedis.search.SearchResult; |
| 18 | +import redis.clients.jedis.search.aggr.AggregationBuilder; |
| 19 | +import redis.clients.jedis.search.aggr.AggregationResult; |
12 | 20 | import redis.clients.jedis.util.JedisClusterHashTag;
|
13 | 21 |
|
14 | 22 | public class ClusterCommandObjects extends CommandObjects {
|
@@ -97,114 +105,122 @@ public final CommandObject<ScanResult<byte[]>> scan(byte[] cursor, ScanParams pa
|
97 | 105 | public final CommandObject<Long> waitReplicas(int replicas, long timeout) {
|
98 | 106 | throw new UnsupportedOperationException(CLUSTER_UNSUPPORTED_MESSAGE);
|
99 | 107 | }
|
100 |
| -// |
| 108 | + |
| 109 | + // RediSearch commands |
| 110 | + // TODO: Send RediSearch command to random 'master' node or random hashslot. |
101 | 111 | // boolean searchLite = false;
|
102 |
| -// |
103 |
| -// private <T> CommandObject<T> processSearchCommand(String indexName, CommandObject<T> command) { |
| 112 | + |
| 113 | + private <T> CommandObject<T> processSearchCommand(String indexName, CommandObject<T> command) { |
104 | 114 | // if (searchLite) command.getArguments().processKey(indexName);
|
105 |
| -// return command; |
106 |
| -// } |
107 |
| -// |
108 |
| -// @Override |
109 |
| -// public final CommandObject<String> ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { |
110 |
| -// return processSearchCommand(indexName, super.ftCreate(indexName, indexOptions, schema)); |
111 |
| -// } |
112 |
| -// |
113 |
| -// @Override |
114 |
| -// public final CommandObject<String> ftAlter(String indexName, Schema schema) { |
115 |
| -// return processSearchCommand(indexName, super.ftAlter(indexName, schema)); |
116 |
| -// } |
117 |
| -// |
118 |
| -// @Override |
119 |
| -// public final CommandObject<SearchResult> ftSearch(String indexName, Query query) { |
120 |
| -// return processSearchCommand(indexName, super.ftSearch(indexName, query)); |
121 |
| -// } |
122 |
| -// |
123 |
| -// @Override |
124 |
| -// public final CommandObject<SearchResult> ftSearch(byte[] indexName, Query query) { |
125 |
| -// CommandObject<SearchResult> command = super.ftSearch(indexName, query); |
| 115 | + command.getArguments().processKey(indexName); |
| 116 | + return command; |
| 117 | + } |
| 118 | + |
| 119 | + @Override |
| 120 | + public final CommandObject<String> ftCreate(String indexName, IndexOptions indexOptions, Schema schema) { |
| 121 | + return processSearchCommand(indexName, super.ftCreate(indexName, indexOptions, schema)); |
| 122 | + } |
| 123 | + |
| 124 | + @Override |
| 125 | + public final CommandObject<String> ftAlter(String indexName, Schema schema) { |
| 126 | + return processSearchCommand(indexName, super.ftAlter(indexName, schema)); |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public final CommandObject<SearchResult> ftSearch(String indexName, Query query) { |
| 131 | + return processSearchCommand(indexName, super.ftSearch(indexName, query)); |
| 132 | + } |
| 133 | + |
| 134 | + @Override |
| 135 | + public final CommandObject<SearchResult> ftSearch(byte[] indexName, Query query) { |
| 136 | + CommandObject<SearchResult> command = super.ftSearch(indexName, query); |
126 | 137 | // if (searchLite) command.getArguments().processKey(indexName);
|
127 |
| -// return command; |
128 |
| -// } |
129 |
| -// |
130 |
| -// @Override |
131 |
| -// public CommandObject<String> ftExplain(String indexName, Query query) { |
132 |
| -// return processSearchCommand(indexName, super.ftExplain(indexName, query)); |
133 |
| -// } |
134 |
| -// |
135 |
| -// @Override |
136 |
| -// public CommandObject<List<String>> ftExplainCLI(String indexName, Query query) { |
137 |
| -// return processSearchCommand(indexName, super.ftExplainCLI(indexName, query)); |
138 |
| -// } |
139 |
| -// |
140 |
| -// @Override |
141 |
| -// public CommandObject<AggregationResult> ftAggregate(String indexName, AggregationBuilder aggr) { |
142 |
| -// return processSearchCommand(indexName, super.ftAggregate(indexName, aggr)); |
143 |
| -// } |
144 |
| -// |
145 |
| -// @Override |
146 |
| -// public CommandObject<AggregationResult> ftCursorRead(String indexName, long cursorId, int count) { |
147 |
| -// return processSearchCommand(indexName, super.ftCursorRead(indexName, cursorId, count)); |
148 |
| -// } |
149 |
| -// |
150 |
| -// @Override |
151 |
| -// public CommandObject<String> ftCursorDel(String indexName, long cursorId) { |
152 |
| -// return processSearchCommand(indexName, super.ftCursorDel(indexName, cursorId)); |
153 |
| -// } |
154 |
| -// |
155 |
| -// @Override |
156 |
| -// public CommandObject<String> ftDropIndex(String indexName) { |
157 |
| -// return processSearchCommand(indexName, super.ftDropIndex(indexName)); |
158 |
| -// } |
159 |
| -// |
160 |
| -// @Override |
161 |
| -// public CommandObject<String> ftDropIndexDD(String indexName) { |
162 |
| -// return processSearchCommand(indexName, super.ftDropIndexDD(indexName)); |
163 |
| -// } |
164 |
| -// |
165 |
| -// @Override |
166 |
| -// public CommandObject<String> ftSynUpdate(String indexName, String synonymGroupId, String... terms) { |
167 |
| -// return processSearchCommand(indexName, super.ftSynUpdate(indexName, synonymGroupId, terms)); |
168 |
| -// } |
169 |
| -// |
170 |
| -// @Override |
171 |
| -// public CommandObject<Map<String, List<String>>> ftSynDump(String indexName) { |
172 |
| -// return processSearchCommand(indexName, super.ftSynDump(indexName)); |
173 |
| -// } |
174 |
| -// |
175 |
| -// @Override |
176 |
| -// public CommandObject<Map<String, Object>> ftInfo(String indexName) { |
177 |
| -// return processSearchCommand(indexName, super.ftInfo(indexName)); |
178 |
| -// } |
179 |
| -// |
180 |
| -// @Override |
181 |
| -// public CommandObject<String> ftAliasAdd(String aliasName, String indexName) { |
| 138 | + command.getArguments().processKey(indexName); |
| 139 | + return command; |
| 140 | + } |
| 141 | + |
| 142 | + @Override |
| 143 | + public CommandObject<String> ftExplain(String indexName, Query query) { |
| 144 | + return processSearchCommand(indexName, super.ftExplain(indexName, query)); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public CommandObject<List<String>> ftExplainCLI(String indexName, Query query) { |
| 149 | + return processSearchCommand(indexName, super.ftExplainCLI(indexName, query)); |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public CommandObject<AggregationResult> ftAggregate(String indexName, AggregationBuilder aggr) { |
| 154 | + return processSearchCommand(indexName, super.ftAggregate(indexName, aggr)); |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public CommandObject<AggregationResult> ftCursorRead(String indexName, long cursorId, int count) { |
| 159 | + return processSearchCommand(indexName, super.ftCursorRead(indexName, cursorId, count)); |
| 160 | + } |
| 161 | + |
| 162 | + @Override |
| 163 | + public CommandObject<String> ftCursorDel(String indexName, long cursorId) { |
| 164 | + return processSearchCommand(indexName, super.ftCursorDel(indexName, cursorId)); |
| 165 | + } |
| 166 | + |
| 167 | + @Override |
| 168 | + public CommandObject<String> ftDropIndex(String indexName) { |
| 169 | + return processSearchCommand(indexName, super.ftDropIndex(indexName)); |
| 170 | + } |
| 171 | + |
| 172 | + @Override |
| 173 | + public CommandObject<String> ftDropIndexDD(String indexName) { |
| 174 | + return processSearchCommand(indexName, super.ftDropIndexDD(indexName)); |
| 175 | + } |
| 176 | + |
| 177 | + @Override |
| 178 | + public CommandObject<String> ftSynUpdate(String indexName, String synonymGroupId, String... terms) { |
| 179 | + return processSearchCommand(indexName, super.ftSynUpdate(indexName, synonymGroupId, terms)); |
| 180 | + } |
| 181 | + |
| 182 | + @Override |
| 183 | + public CommandObject<Map<String, List<String>>> ftSynDump(String indexName) { |
| 184 | + return processSearchCommand(indexName, super.ftSynDump(indexName)); |
| 185 | + } |
| 186 | + |
| 187 | + @Override |
| 188 | + public CommandObject<Map<String, Object>> ftInfo(String indexName) { |
| 189 | + return processSearchCommand(indexName, super.ftInfo(indexName)); |
| 190 | + } |
| 191 | + |
| 192 | + @Override |
| 193 | + public CommandObject<String> ftAliasAdd(String aliasName, String indexName) { |
182 | 194 | // CommandObject<String> command = super.ftAliasAdd(aliasName, indexName);
|
183 | 195 | // if (searchLite) command.getArguments().processKey(aliasName).processKey(indexName);
|
184 | 196 | // return command;
|
185 |
| -// } |
186 |
| -// |
187 |
| -// @Override |
188 |
| -// public CommandObject<String> ftAliasUpdate(String aliasName, String indexName) { |
| 197 | + return processSearchCommand(indexName, super.ftAliasAdd(aliasName, indexName)); |
| 198 | + } |
| 199 | + |
| 200 | + @Override |
| 201 | + public CommandObject<String> ftAliasUpdate(String aliasName, String indexName) { |
189 | 202 | // CommandObject<String> command = super.ftAliasUpdate(aliasName, indexName);
|
190 | 203 | // if (searchLite) command.getArguments().processKey(aliasName).processKey(indexName);
|
191 | 204 | // return command;
|
192 |
| -// } |
193 |
| -// |
194 |
| -// @Override |
195 |
| -// public CommandObject<String> ftAliasDel(String aliasName) { |
| 205 | + return processSearchCommand(indexName, super.ftAliasUpdate(aliasName, indexName)); |
| 206 | + } |
| 207 | + |
| 208 | + @Override |
| 209 | + public CommandObject<String> ftAliasDel(String aliasName) { |
196 | 210 | // CommandObject<String> command = super.ftAliasDel(aliasName);
|
197 | 211 | // if (searchLite) command.getArguments().processKey(aliasName);
|
198 | 212 | // return command;
|
199 |
| -// } |
200 |
| -// |
201 |
| -// @Override |
202 |
| -// public CommandObject<Map<String, String>> ftConfigGet(String indexName, String option) { |
203 |
| -// return processSearchCommand(indexName, super.ftConfigGet(indexName, option)); |
204 |
| -// } |
205 |
| -// |
206 |
| -// @Override |
207 |
| -// public CommandObject<String> ftConfigSet(String indexName, String option, String value) { |
208 |
| -// return processSearchCommand(indexName, super.ftConfigSet(indexName, option, value)); |
209 |
| -// } |
| 213 | + return processSearchCommand(aliasName, super.ftAliasDel(aliasName)); |
| 214 | + } |
| 215 | + |
| 216 | + @Override |
| 217 | + public CommandObject<Map<String, String>> ftConfigGet(String indexName, String option) { |
| 218 | + return processSearchCommand(indexName, super.ftConfigGet(indexName, option)); |
| 219 | + } |
| 220 | + |
| 221 | + @Override |
| 222 | + public CommandObject<String> ftConfigSet(String indexName, String option, String value) { |
| 223 | + return processSearchCommand(indexName, super.ftConfigSet(indexName, option, value)); |
| 224 | + } |
| 225 | + // RediSearch commands |
210 | 226 | }
|
0 commit comments