Shinsuke Sugaya hace 10 años
padre
commit
ba7fb9f03a

+ 6 - 4
src/main/java/org/codelibs/fess/client/SearchClient.java

@@ -305,10 +305,12 @@ public class SearchClient {
         return query.execute().actionGet();
         return query.execute().actionGet();
     }
     }
 
 
-    public void update(String id, String field, Object value) {
-        UpdateResponse response = client.prepareUpdate(index, type, id).setDoc(field, value).execute().actionGet();
-        // TODO
-
+    public boolean update(String id, String field, Object value) {
+        try {
+            return client.prepareUpdate(index, type, id).setDoc(field, value).execute().actionGet().isCreated();
+        } catch (ElasticsearchException e) {
+            throw new SearchException("Failed to set " + value + " to " + field + " for doc " + id, e);
+        }
     }
     }
 
 
     public void refresh() {
     public void refresh() {

+ 1 - 0
src/main/java/org/codelibs/fess/helper/impl/SearchLogHelperImpl.java

@@ -197,6 +197,7 @@ public class SearchLogHelperImpl extends SearchLogHelper {
         final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
         final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
         for (final Map.Entry<String, Long> entry : clickCountMap.entrySet()) {
         for (final Map.Entry<String, Long> entry : clickCountMap.entrySet()) {
             try {
             try {
+                // TODO buik update
                 documentHelper.update(entry.getKey(), fieldHelper.clickCountField, entry.getValue() + 1);
                 documentHelper.update(entry.getKey(), fieldHelper.clickCountField, entry.getValue() + 1);
             } catch (final Exception e) {
             } catch (final Exception e) {
                 logger.warn("Failed to update a clickCount(" + entry.getValue() + ") for " + entry.getKey(), e);
                 logger.warn("Failed to update a clickCount(" + entry.getValue() + ") for " + entry.getKey(), e);