This commit is contained in:
Shinsuke Sugaya 2015-05-12 06:41:12 +09:00
parent c17398f523
commit ba7fb9f03a
2 changed files with 7 additions and 4 deletions

View file

@ -305,10 +305,12 @@ public class SearchClient {
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() {

View file

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