@author Nikita Koksharov
| 52 | * |
| 53 | */ |
| 54 | public class RedissonSearch implements RSearch { |
| 55 | |
| 56 | private final Codec codec; |
| 57 | private final CommandAsyncExecutor commandExecutor; |
| 58 | |
| 59 | public RedissonSearch(CommandAsyncExecutor commandExecutor) { |
| 60 | this.codec = commandExecutor.getServiceManager().getCfg().getCodec(); |
| 61 | this.commandExecutor = commandExecutor; |
| 62 | } |
| 63 | |
| 64 | public RedissonSearch(Codec codec, CommandAsyncExecutor commandExecutor) { |
| 65 | this.codec = commandExecutor.getServiceManager().getCodec(codec); |
| 66 | this.commandExecutor = commandExecutor; |
| 67 | } |
| 68 | |
| 69 | private boolean isClusterMode() { |
| 70 | return commandExecutor.getServiceManager().getCfg().isClusterConfig(); |
| 71 | } |
| 72 | |
| 73 | private Map<Long, MasterSlaveEntry> cursorRoutes() { |
| 74 | return commandExecutor.getServiceManager().getSearchCursorRoutes(); |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public void createIndex(String indexName, IndexOptions options, FieldIndex... fields) { |
| 79 | commandExecutor.get(createIndexAsync(indexName, options, fields)); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public RFuture<Void> createIndexAsync(String indexName, IndexOptions options, FieldIndex... fields) { |
| 84 | if (fields.length == 0) { |
| 85 | throw new IllegalArgumentException("At least one field index should be defined"); |
| 86 | } |
| 87 | List<Object> args = new ArrayList<>(); |
| 88 | args.add(indexName); |
| 89 | if (options.getOn() != null) { |
| 90 | args.add("ON"); |
| 91 | args.add(options.getOn()); |
| 92 | } |
| 93 | if (!options.getPrefix().isEmpty()) { |
| 94 | args.add("PREFIX"); |
| 95 | args.add(options.getPrefix().size()); |
| 96 | args.addAll(options.getPrefix()); |
| 97 | } |
| 98 | if (options.getFilter() != null) { |
| 99 | args.add("FILTER"); |
| 100 | args.add(options.getFilter()); |
| 101 | } |
| 102 | if (options.getLanguage() != null) { |
| 103 | args.add("LANGUAGE"); |
| 104 | args.add(options.getLanguage()); |
| 105 | } |
| 106 | if (options.getLanguageField() != null) { |
| 107 | args.add("LANGUAGE_FIELD"); |
| 108 | args.add(options.getLanguageField()); |
| 109 | } |
| 110 | if (options.getScore() != null) { |
| 111 | args.add("SCORE"); |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…