瀏覽代碼

fix crawling problem

Shinsuke Sugaya 9 年之前
父節點
當前提交
f88b2cba12

+ 2 - 2
pom.xml

@@ -283,7 +283,7 @@
 							<url
 								url="${maven.snapshot.repo.url}/org/codelibs/elasticsearch-configsync/2.0.0-SNAPSHOT/elasticsearch-configsync-2.0.0-20151113.133045-4.zip" />
 							<url
-								url="${maven.snapshot.repo.url}/org/codelibs/elasticsearch-langfield/2.0.0-SNAPSHOT/elasticsearch-langfield-2.0.0-20151113.132901-3.zip" />
+								url="${maven.snapshot.repo.url}/org/codelibs/elasticsearch-langfield/2.0.0-SNAPSHOT/elasticsearch-langfield-2.0.0-20151126.010100-4.zip" />
 							<url
 								url="http://maven.codelibs.org/archive/elasticsearch/plugin/kopf/elasticsearch-kopf-2.0.0.0.zip" />
 						</get>
@@ -296,7 +296,7 @@
 						<unzip dest="${basedir}/plugins/configsync"
 							src="${basedir}/target/plugins/elasticsearch-configsync-2.0.0-20151113.133045-4.zip" />
 						<unzip dest="${basedir}/plugins/langfield"
-							src="${basedir}/target/plugins/elasticsearch-langfield-2.0.0-20151113.132901-3.zip" />
+							src="${basedir}/target/plugins/elasticsearch-langfield-2.0.0-20151126.010100-4.zip" />
 						<unzip dest="${basedir}/plugins/kopf"
 							src="${basedir}/target/plugins/elasticsearch-kopf-2.0.0.0.zip" />
 					</tasks>

+ 16 - 0
src/main/java/org/codelibs/fess/es/client/FessEsClient.java

@@ -70,6 +70,8 @@ import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
 import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
 import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse;
 import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
+import org.elasticsearch.action.bulk.BulkItemResponse;
+import org.elasticsearch.action.bulk.BulkItemResponse.Failure;
 import org.elasticsearch.action.bulk.BulkRequest;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
@@ -748,6 +750,20 @@ public class FessEsClient implements Client {
         }
         final BulkResponse response = bulkRequestBuilder.execute().actionGet();
         if (response.hasFailures()) {
+            if (logger.isDebugEnabled()) {
+                List<ActionRequest> requests = bulkRequestBuilder.request().requests();
+                BulkItemResponse[] items = response.getItems();
+                if (requests.size() == items.length) {
+                    for (int i = 0; i < requests.size(); i++) {
+                        BulkItemResponse resp = items[i];
+                        if (resp.isFailed() && resp.getFailure() != null) {
+                            ActionRequest req = requests.get(i);
+                            Failure failure = resp.getFailure();
+                            logger.debug("Failed Request: " + req + "\n=>" + failure.getMessage());
+                        }
+                    }
+                }
+            }
             throw new FessEsClientException(response.buildFailureMessage());
         }
     }

+ 11 - 8
src/main/java/org/codelibs/fess/helper/IndexingHelper.java

@@ -42,15 +42,18 @@ public class IndexingHelper {
         if (logger.isDebugEnabled()) {
             logger.debug("Sending " + docList.size() + " documents to a server.");
         }
-        synchronized (fessEsClient) {
-            deleteOldDocuments(fessEsClient, docList);
-            final FessConfig fessConfig = ComponentUtil.getFessConfig();
-            fessEsClient.addAll(fessConfig.getIndexDocumentIndex(), fessConfig.getIndexDocumentType(), docList);
-        }
-        if (logger.isInfoEnabled()) {
-            logger.info("Sent " + docList.size() + " docs (" + (System.currentTimeMillis() - execTime) + "ms)");
+        try {
+            synchronized (fessEsClient) {
+                deleteOldDocuments(fessEsClient, docList);
+                final FessConfig fessConfig = ComponentUtil.getFessConfig();
+                fessEsClient.addAll(fessConfig.getIndexDocumentIndex(), fessConfig.getIndexDocumentType(), docList);
+            }
+            if (logger.isInfoEnabled()) {
+                logger.info("Sent " + docList.size() + " docs (" + (System.currentTimeMillis() - execTime) + "ms)");
+            }
+        } finally {
+            docList.clear();
         }
-        docList.clear();
     }
 
     private void deleteOldDocuments(final FessEsClient fessEsClient, final List<Map<String, Object>> docList) {