diff --git a/dbflute.xml b/dbflute.xml index 25a11fa5f..caea3188f 100644 --- a/dbflute.xml +++ b/dbflute.xml @@ -2,7 +2,7 @@ - + diff --git a/plugin.xml b/plugin.xml index 70fd5e686..3f267228b 100644 --- a/plugin.xml +++ b/plugin.xml @@ -15,57 +15,57 @@ - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + diff --git a/pom.xml b/pom.xml index 45b7aabab..c5a588ab6 100644 --- a/pom.xml +++ b/pom.xml @@ -60,12 +60,12 @@ 1.2.0-SNAPSHOT - 5.2.1-SNAPSHOT + 5.3.0-SNAPSHOT - 5.2.2 - 5.1.0 - 5.2.2.0 + 5.3.0 + 5.3.0 + 5.3.0.0 8.5.11 diff --git a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java index 550aedbd0..321436c1c 100644 --- a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java +++ b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java @@ -69,6 +69,8 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.ActionResponse; +import org.elasticsearch.action.DocWriteRequest; +import org.elasticsearch.action.DocWriteRequest.OpType; import org.elasticsearch.action.DocWriteResponse.Result; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; @@ -100,7 +102,6 @@ import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; import org.elasticsearch.action.index.IndexRequest; -import org.elasticsearch.action.index.IndexRequest.OpType; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.ClearScrollRequest; @@ -135,6 +136,7 @@ import org.elasticsearch.common.settings.Settings.Builder; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHitField; @@ -318,7 +320,7 @@ public class FessEsClient implements Client { source = FileUtil.readUTF8(filePath); try (CurlResponse response = Curl.post(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/file") - .param("path", path).body(source).execute()) { + .header("Content-Type", "application/json").param("path", path).body(source).execute()) { if (response.getHttpStatusCode() == 200) { logger.info("Register " + path + " to " + configIndex); } else { @@ -335,7 +337,8 @@ public class FessEsClient implements Client { } }); try (CurlResponse response = - Curl.post(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/flush").execute()) { + Curl.post(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/flush") + .header("Content-Type", "application/json").execute()) { if (response.getHttpStatusCode() == 200) { logger.info("Flushed config files."); } else { @@ -357,7 +360,8 @@ public class FessEsClient implements Client { final String dictionaryPath = System.getProperty("fess.dictionary.path", StringUtil.EMPTY); source = source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath); final CreateIndexResponse indexResponse = - client.admin().indices().prepareCreate(createdIndexName).setSource(source).execute() + client.admin().indices().prepareCreate(createdIndexName) + .setSource(source, XContentFactory.xContentType(source)).execute() .actionGet(fessConfig.getIndexIndicesTimeout()); if (indexResponse.isAcknowledged()) { logger.info("Created " + createdIndexName + " index."); @@ -426,7 +430,8 @@ public class FessEsClient implements Client { } try { final PutMappingResponse putMappingResponse = - client.admin().indices().preparePutMapping(updatedIndexName).setType(configType).setSource(source).execute() + client.admin().indices().preparePutMapping(updatedIndexName).setType(configType) + .setSource(source, XContentFactory.xContentType(source)).execute() .actionGet(fessConfig.getIndexIndicesTimeout()); if (putMappingResponse.isAcknowledged()) { logger.info("Created " + updatedIndexName + "/" + configType + " mapping."); @@ -478,7 +483,8 @@ public class FessEsClient implements Client { }); if (result.keySet().contains("index")) { final IndexRequestBuilder requestBuilder = - client.prepareIndex(configIndex, configType, result.get("index").get("_id")).setSource(line); + client.prepareIndex(configIndex, configType, result.get("index").get("_id")).setSource(line, + XContentFactory.xContentType(line)); builder.add(requestBuilder); } } @@ -507,8 +513,8 @@ public class FessEsClient implements Client { private void waitForConfigSyncStatus() { try (CurlResponse response = - Curl.get(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/wait").param("status", "green") - .execute()) { + Curl.get(org.codelibs.fess.util.ResourceUtil.getElasticsearchHttpUrl() + "/_configsync/wait") + .header("Content-Type", "application/json").param("status", "green").execute()) { if (response.getHttpStatusCode() == 200) { logger.info("ConfigSync is ready."); } else { @@ -768,13 +774,14 @@ public class FessEsClient implements Client { final BulkResponse response = bulkRequestBuilder.execute().actionGet(ComponentUtil.getFessConfig().getIndexBulkTimeout()); if (response.hasFailures()) { if (logger.isDebugEnabled()) { - final List requests = bulkRequestBuilder.request().requests(); + @SuppressWarnings("rawtypes") + final List requests = bulkRequestBuilder.request().requests(); final BulkItemResponse[] items = response.getItems(); if (requests.size() == items.length) { for (int i = 0; i < requests.size(); i++) { final BulkItemResponse resp = items[i]; if (resp.isFailed() && resp.getFailure() != null) { - final ActionRequest req = requests.get(i); + final DocWriteRequest req = requests.get(i); final Failure failure = resp.getFailure(); logger.debug("Failed Request: " + req + "\n=>" + failure.getMessage()); } @@ -924,6 +931,7 @@ public class FessEsClient implements Client { public boolean store(final String index, final String type, final Object obj) { final FessConfig fessConfig = ComponentUtil.getFessConfig(); + @SuppressWarnings("unchecked") final Map source = obj instanceof Map ? (Map) obj : BeanUtil.copyBeanToNewMap(obj); final String id = (String) source.remove(fessConfig.getIndexFieldId()); final Long version = (Long) source.remove(fessConfig.getIndexFieldVersion()); diff --git a/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java b/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java index d6cd1b2f2..fa4f6b5a1 100644 --- a/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java +++ b/src/test/java/org/codelibs/fess/entity/GeoInfoTest.java @@ -27,7 +27,7 @@ public class GeoInfoTest extends UnitFessTestCase { final GeoInfo geoInfo = new GeoInfo(request); String result = - "{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"sloppy_arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}"; + "{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}"; assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", "")); } @@ -38,7 +38,7 @@ public class GeoInfoTest extends UnitFessTestCase { final GeoInfo geoInfo = new GeoInfo(request); String result = - "{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"sloppy_arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}"; + "{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}"; assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", "")); } @@ -51,7 +51,7 @@ public class GeoInfoTest extends UnitFessTestCase { final GeoInfo geoInfo = new GeoInfo(request); String result = - "{\"bool\":{\"should\":[{\"geo_distance\":{\"location\":[151.0,35.0],\"distance\":1000.0,\"distance_type\":\"sloppy_arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}},{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"sloppy_arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}],\"disable_coord\":false,\"adjust_pure_negative\":true,\"boost\":1.0}}"; + "{\"bool\":{\"should\":[{\"geo_distance\":{\"location\":[151.0,35.0],\"distance\":1000.0,\"distance_type\":\"arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}},{\"geo_distance\":{\"location\":[150.0,34.0],\"distance\":10000.0,\"distance_type\":\"arc\",\"validation_method\":\"STRICT\",\"ignore_unmapped\":false,\"boost\":1.0}}],\"disable_coord\":false,\"adjust_pure_negative\":true,\"boost\":1.0}}"; assertEquals(result, geoInfo.toQueryBuilder().toString().replaceAll("[ \n]", "")); }