|
@@ -22,13 +22,18 @@ import java.util.Map;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
|
import jp.sf.fess.FessSystemException;
|
|
import jp.sf.fess.FessSystemException;
|
|
|
|
+import jp.sf.fess.db.bsbhv.BsFavoriteLogBhv;
|
|
import jp.sf.fess.db.cbean.ClickLogCB;
|
|
import jp.sf.fess.db.cbean.ClickLogCB;
|
|
import jp.sf.fess.db.exbhv.ClickLogBhv;
|
|
import jp.sf.fess.db.exbhv.ClickLogBhv;
|
|
|
|
+import jp.sf.fess.db.exbhv.FavoriteLogBhv;
|
|
|
|
+import jp.sf.fess.db.exbhv.pmbean.FavoriteUrlCountPmb;
|
|
|
|
+import jp.sf.fess.db.exentity.customize.FavoriteUrlCount;
|
|
import jp.sf.fess.ds.IndexUpdateCallback;
|
|
import jp.sf.fess.ds.IndexUpdateCallback;
|
|
import jp.sf.fess.helper.CrawlingSessionHelper;
|
|
import jp.sf.fess.helper.CrawlingSessionHelper;
|
|
|
|
|
|
import org.apache.solr.common.SolrInputDocument;
|
|
import org.apache.solr.common.SolrInputDocument;
|
|
import org.codelibs.solr.lib.SolrGroup;
|
|
import org.codelibs.solr.lib.SolrGroup;
|
|
|
|
+import org.seasar.dbflute.cbean.ListResultBean;
|
|
import org.seasar.framework.container.SingletonS2Container;
|
|
import org.seasar.framework.container.SingletonS2Container;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -43,8 +48,12 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|
|
|
|
|
public boolean clickCountEnabled = true;
|
|
public boolean clickCountEnabled = true;
|
|
|
|
|
|
|
|
+ public boolean favoriteCountEnabled = true;
|
|
|
|
+
|
|
public String clickCountField = "clickCount_i";
|
|
public String clickCountField = "clickCount_i";
|
|
|
|
|
|
|
|
+ public String favoriteCountField = "favoriteCount_i";
|
|
|
|
+
|
|
protected volatile AtomicLong documentSize = new AtomicLong(0);
|
|
protected volatile AtomicLong documentSize = new AtomicLong(0);
|
|
|
|
|
|
protected volatile long commitPerCount = 0;
|
|
protected volatile long commitPerCount = 0;
|
|
@@ -64,8 +73,9 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|
logger.debug("Adding " + dataMap);
|
|
logger.debug("Adding " + dataMap);
|
|
}
|
|
}
|
|
|
|
|
|
- // TODO required check
|
|
|
|
- if (!dataMap.containsKey("url") || dataMap.get("url") == null) {
|
|
|
|
|
|
+ // required check
|
|
|
|
+ final Object urlObj = dataMap.get("url");
|
|
|
|
+ if (urlObj == null) {
|
|
throw new FessSystemException("url is null. dataMap=" + dataMap);
|
|
throw new FessSystemException("url is null. dataMap=" + dataMap);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -89,7 +99,11 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|
}
|
|
}
|
|
|
|
|
|
if (clickCountEnabled) {
|
|
if (clickCountEnabled) {
|
|
- addClickCountField(doc, dataMap.get("url").toString());
|
|
|
|
|
|
+ addClickCountField(doc, urlObj.toString());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (favoriteCountEnabled) {
|
|
|
|
+ addFavoriteCountField(doc, urlObj.toString());
|
|
}
|
|
}
|
|
|
|
|
|
docList.add(doc);
|
|
docList.add(doc);
|
|
@@ -170,6 +184,27 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected void addFavoriteCountField(final SolrInputDocument doc,
|
|
|
|
+ final String url) {
|
|
|
|
+ final FavoriteLogBhv favoriteLogBhv = SingletonS2Container
|
|
|
|
+ .getComponent(FavoriteLogBhv.class);
|
|
|
|
+ final FavoriteUrlCountPmb pmb = new FavoriteUrlCountPmb();
|
|
|
|
+ pmb.setUrl(url);
|
|
|
|
+ final String path = BsFavoriteLogBhv.PATH_selectFavoriteUrlCount;
|
|
|
|
+ final ListResultBean<FavoriteUrlCount> list = favoriteLogBhv
|
|
|
|
+ .outsideSql().selectList(path, pmb, FavoriteUrlCount.class);
|
|
|
|
+
|
|
|
|
+ long count = 0;
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
+ count = list.get(0).getCnt().longValue();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ doc.addField(favoriteCountField, count);
|
|
|
|
+ if (logger.isDebugEnabled()) {
|
|
|
|
+ logger.debug("Favorite Count: " + count + ", url: " + url);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public long getDocumentSize() {
|
|
public long getDocumentSize() {
|
|
return documentSize.get();
|
|
return documentSize.get();
|