Skip to content

Commit

Permalink
extra logging, and upgraded dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimpza committed Apr 24, 2020
1 parent ad9c94f commit 350c011
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ repositories {
}

dependencies {
implementation 'com.redislabs:jredisearch:1.2.0'
implementation 'io.undertow:undertow-core:2.0.28.Final'
implementation 'com.redislabs:jredisearch:1.6.0'
implementation 'io.undertow:undertow-core:2.1.0.Final'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.10.1'
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/shrimpworks/mes/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ public static void main(String[] args) throws IOException {
if (!Files.exists(configPath) || !Files.isRegularFile(configPath)) {
System.err.printf("Config file %s does not exist%n", configPath.toString());
System.exit(3);
} else {
System.out.printf("Using configuration in file %s%n", configPath);
}

Config config = JacksonMapper.YAML.object(configPath, Config.class);
String[] redis = config.redisearch.split(":");
Client client = new Client(config.index, redis[0], redis.length > 1 ? Integer.parseInt(redis[1]) : 6379);
try {
client.createIndex(config.schema.toSchema(), Client.IndexOptions.defaultOptions());
System.out.printf("Created index %s%n", config.index);
} catch (JedisDataException je) {
if (je.getMessage().contains("already exists")) {
System.out.printf("Index %s already exists, updating%n", config.index);
// if the index already exists, we can make an attempt at adding fields (there's no api for deleting fields)
List<List<Object>> fields = (List<List<Object>>)client.getInfo().get("fields");
Set<String> fieldNames = fields.stream()
Expand Down

0 comments on commit 350c011

Please sign in to comment.