|
@@ -0,0 +1,556 @@
|
|
|
|
|
+package istyle;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.LinkedHashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+import org.json.simple.JSONObject;
|
|
|
|
|
+
|
|
|
|
|
+import com.diquest.ir.client.command.CommandSearchRequest;
|
|
|
|
|
+import com.diquest.ir.common.exception.IRException;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.Protocol;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.SelectSet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.WhereSet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.result.GroupResult;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.result.Result;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.result.ResultSet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.FilterSet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.GroupBySet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.OrderBySet;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.Query;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.QueryParser;
|
|
|
|
|
+import com.diquest.ir.common.msg.protocol.query.QuerySet;
|
|
|
|
|
+
|
|
|
|
|
+public class AutoSearch {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static ArrayList<SelectSet> getSelectSet() {
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<SelectSet> selectSetList = new ArrayList<SelectSet>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_NM",(byte)(Protocol.SelectSet.HIGHLIGHT),200));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_GB"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("FOREIGN_BUY_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("PARALLEL_IMPORT_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("ORDER_MADE_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_SNM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("BRAND_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("ITEMKIND_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("FORMAL_GB"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("LIST_PRICE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("CURR_PRICE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SELF_GOODS_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_STAT"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("PNT_PRATE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("PRE_PPNT_USABLE_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("PNT_MRATE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("PRE_MPNT_USABLE_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("MIN_ORD_QTY"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("MAX_ORD_QTY"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("DAY_MAX_ORD_QTY"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SEX_GB"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("MAIN_COLOR_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SUPPLY_COMP_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SELF_MALL_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("AGE_GRP_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SEASON_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_TYPE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("REG_DT"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("BRAND_GROUP_NM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("BRAND_GROUP_NO"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("DELV_FEE"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("MIN_ORD_AMT"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("ORDER_CNT"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("REVIEW_CNT"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SIZE_GB"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SIZE_GB_NM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("QUIK_DELV_YN"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("COLOR_CD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SIZES"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("CPN_PC_ICON"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("CPN_MO_ICON"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("CPN_APP_ICON"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("FREEGIFT_ICON"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("AD_KEYWORD"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("VIDEO_GB_M"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("VIDEO_VAL_M"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("VIDEO_GB_S"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("VIDEO_VAL_S"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("GOODS_GB_NM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SEX_NM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("AGE_GRP_NM"));
|
|
|
|
|
+ selectSetList.add(new SelectSet("SEASON_NM"));
|
|
|
|
|
+
|
|
|
|
|
+ return selectSetList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static ArrayList<WhereSet> getWhereSet(String searchTerm) {
|
|
|
|
|
+ ArrayList<WhereSet> WhereSetList = new ArrayList<WhereSet>();
|
|
|
|
|
+
|
|
|
|
|
+ ///////////////////////////////
|
|
|
|
|
+ if (!searchTerm.equals("")) {
|
|
|
|
|
+ WhereSetList.add(new WhereSet(Protocol.WhereSet.OP_BRACE_OPEN));
|
|
|
|
|
+ WhereSetList.add(new WhereSet("IDX_GOODS_NM", Protocol.WhereSet.OP_HASALL, searchTerm, 100));
|
|
|
|
|
+ WhereSetList.add(new WhereSet(Protocol.WhereSet.OP_OR));
|
|
|
|
|
+ WhereSetList.add(new WhereSet("IDX_GOODS_NM_BI", Protocol.WhereSet.OP_HASALL, searchTerm, 100));
|
|
|
|
|
+ WhereSetList.add(new WhereSet(Protocol.WhereSet.OP_BRACE_CLOSE));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return WhereSetList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static OrderBySet [] getOrderBySet() {
|
|
|
|
|
+
|
|
|
|
|
+ OrderBySet [] orderBySet = null;
|
|
|
|
|
+
|
|
|
|
|
+ orderBySet = new OrderBySet[1];
|
|
|
|
|
+
|
|
|
|
|
+ orderBySet = new OrderBySet[] { new OrderBySet(false,"WEIGHT", Protocol.OrderBySet.OP_POSTWEIGHT)};
|
|
|
|
|
+
|
|
|
|
|
+ return orderBySet;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static GroupBySet [] getGroupBySet() {
|
|
|
|
|
+
|
|
|
|
|
+ GroupBySet [] groupBySet = null;
|
|
|
|
|
+
|
|
|
|
|
+ groupBySet = new GroupBySet[2];
|
|
|
|
|
+ groupBySet = new GroupBySet[] {
|
|
|
|
|
+ new GroupBySet("GROUP_FULL_CATE_NO", (byte) (Protocol.GroupBySet.OP_COUNT | Protocol.GroupBySet.ORDER_COUNT), "DESC"),
|
|
|
|
|
+ new GroupBySet("GROUP_FULL_CATE_NM", (byte) (Protocol.GroupBySet.OP_COUNT | Protocol.GroupBySet.ORDER_COUNT), "DESC"),
|
|
|
|
|
+ new GroupBySet("GROUP_BRAND_CD", (byte) (Protocol.GroupBySet.OP_COUNT | Protocol.GroupBySet.ORDER_COUNT), "DESC"),
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ return groupBySet;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static JSONObject benerSearchApi(Map<String, Object> parameter) {
|
|
|
|
|
+
|
|
|
|
|
+ //------- Parameter ---------------
|
|
|
|
|
+ String adminIp = (String)parameter.get("adminIp"); //Ip
|
|
|
|
|
+ int adminPort = (Integer)parameter.get("adminPort"); //Port
|
|
|
|
|
+
|
|
|
|
|
+ String searchKeyword = (String)parameter.get("searchKeyword");if (searchKeyword == null) {searchKeyword = "";} //Search Word
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //------- Mariner API ----------------
|
|
|
|
|
+ int queryCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ QuerySet querySet = new QuerySet(1);
|
|
|
|
|
+ QueryParser queryParser = new QueryParser(); //QueryParser
|
|
|
|
|
+ WhereSet [] whereSet = null; //WhereSet[]
|
|
|
|
|
+ SelectSet [] selectSet = null; //SelectSet[]
|
|
|
|
|
+ OrderBySet[] orderBySet = null; //OrderBySet[]
|
|
|
|
|
+ GroupBySet[] groupBySet = null; //GroupBySet[]
|
|
|
|
|
+
|
|
|
|
|
+ int returnCode = -1;
|
|
|
|
|
+ int indexs = 0;
|
|
|
|
|
+ int counts = 5;
|
|
|
|
|
+
|
|
|
|
|
+ CommandSearchRequest command = null;
|
|
|
|
|
+
|
|
|
|
|
+ String startTag = "<Strong>";
|
|
|
|
|
+ String endTag = "</Strong>";
|
|
|
|
|
+
|
|
|
|
|
+ Query query = new Query(startTag, endTag);
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<SelectSet> selectSetList = null;
|
|
|
|
|
+ ArrayList<WhereSet> whereSetList = null;
|
|
|
|
|
+ SelectSet[] getSelectSetFiels = null;
|
|
|
|
|
+
|
|
|
|
|
+ selectSetList = getSelectSet();
|
|
|
|
|
+ selectSet = new SelectSet[selectSetList.size()];
|
|
|
|
|
+
|
|
|
|
|
+ for(int a=0;a<selectSetList.size();a++){
|
|
|
|
|
+ selectSet[a] = selectSetList.get(a);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //whereSet
|
|
|
|
|
+ whereSetList = getWhereSet(searchKeyword);
|
|
|
|
|
+ whereSet = new WhereSet[whereSetList.size()];
|
|
|
|
|
+
|
|
|
|
|
+ for(int b=0;b<whereSetList.size();b++){
|
|
|
|
|
+ whereSet[b] = whereSetList.get(b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ orderBySet = getOrderBySet();
|
|
|
|
|
+ query.setOrderby(orderBySet);
|
|
|
|
|
+
|
|
|
|
|
+ groupBySet = getGroupBySet();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ query.setSelect(selectSet);
|
|
|
|
|
+ query.setWhere(whereSet);
|
|
|
|
|
+ //query.setFilter(filterSet);
|
|
|
|
|
+ query.setGroupBy(groupBySet);
|
|
|
|
|
+ query.setFrom("GOODS");
|
|
|
|
|
+ query.setResult(0 , 6);
|
|
|
|
|
+ query.setDebug(true);
|
|
|
|
|
+ query.setLoggable(true);
|
|
|
|
|
+ query.setSearchKeyword(searchKeyword);
|
|
|
|
|
+ query.setThesaurusOption((byte) (Protocol.ThesaurusOption.EQUIV_SYNONYM | Protocol.ThesaurusOption.QUASI_SYNONYM));
|
|
|
|
|
+ query.setPrintQuery(true);
|
|
|
|
|
+ querySet.addQuery(query);
|
|
|
|
|
+ System.out.println("##### query0= " + queryParser.queryToString(query));
|
|
|
|
|
+
|
|
|
|
|
+ getSelectSetFiels = query.getSelectFields();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //------- Result ------------------
|
|
|
|
|
+ Result[] resultlist = null;
|
|
|
|
|
+ LinkedHashMap<String, String> resultMap = new LinkedHashMap<String, String>();
|
|
|
|
|
+ Result result = null;
|
|
|
|
|
+ String totalSize = "";
|
|
|
|
|
+ List<Map<String, String>> List = null;
|
|
|
|
|
+ List<String> cateCdList = new ArrayList<String>();
|
|
|
|
|
+ List<String> cateNmList = new ArrayList<String>();
|
|
|
|
|
+ List<String> brandList = new ArrayList<String>();
|
|
|
|
|
+ LinkedHashMap<String, List<String>> groupMap = new LinkedHashMap<String, List<String>>();
|
|
|
|
|
+ Map<String, String> totalMap = new HashMap<String, String>(); //검색 결과 개수
|
|
|
|
|
+ List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
|
|
|
|
|
+ List<Object> groupList = new ArrayList<Object>();
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+
|
|
|
|
|
+ //---------------------------------
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!searchKeyword.equals("")) {
|
|
|
|
|
+ command = new CommandSearchRequest(adminIp, adminPort);
|
|
|
|
|
+ returnCode = command.request(querySet);
|
|
|
|
|
+ System.out.println("returnCode ########## : " + returnCode);
|
|
|
|
|
+ if (returnCode > 0) {
|
|
|
|
|
+ ResultSet results = command.getResultSet();
|
|
|
|
|
+ resultlist = results.getResultList();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ resultlist = new Result[1];
|
|
|
|
|
+ resultlist[0] = new Result();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int k = 0; resultlist != null && k < resultlist.length; k++) {
|
|
|
|
|
+
|
|
|
|
|
+ result = resultlist[k];
|
|
|
|
|
+ resultList = new ArrayList<Map<String,String>>();
|
|
|
|
|
+
|
|
|
|
|
+ if (result != null) {
|
|
|
|
|
+ // total
|
|
|
|
|
+ totalSize = Integer.toString(result.getTotalSize());
|
|
|
|
|
+ totalMap.put("TOTAL", totalSize);
|
|
|
|
|
+ // 검색결과
|
|
|
|
|
+ for (int i = 0; i < result.getRealSize(); i++) {
|
|
|
|
|
+ resultMap = new LinkedHashMap<String, String>();
|
|
|
|
|
+ for (int j = 0 ; j < result.getNumField(); j++) {
|
|
|
|
|
+ resultMap.put(convert2CamelCase(new String(getSelectSetFiels[j].getField())), new String(result.getResult(i,j)));
|
|
|
|
|
+ //resultMap.put(new String(getSelectSetFiels[j].getField()), new String(result.getResult(i,j)));
|
|
|
|
|
+ }
|
|
|
|
|
+ resultList.add(resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (result.getGroupResultSize() != 0) {
|
|
|
|
|
+ GroupResult[] groupResults = result.getGroupResults();
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < groupResults.length; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ int rSize = groupResults[i].groupResultSize();
|
|
|
|
|
+ groupMap = new LinkedHashMap<String, List<String>>();
|
|
|
|
|
+
|
|
|
|
|
+ for (int j = 0; j < rSize; j++) {
|
|
|
|
|
+
|
|
|
|
|
+ String id = new String(groupResults[i].getId(j));
|
|
|
|
|
+
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
|
+ cateCdList.add(id);
|
|
|
|
|
+ groupMap.put("cateCd", cateCdList);
|
|
|
|
|
+ }else if(i == 1) {
|
|
|
|
|
+ cateNmList.add(id);
|
|
|
|
|
+ groupMap.put("cateNm", cateNmList);
|
|
|
|
|
+ }else if(i == 2) {
|
|
|
|
|
+ brandList.add(id);
|
|
|
|
|
+ groupMap.put("brand", brandList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ groupList.add(groupMap);
|
|
|
|
|
+ //groupList.add(resultMap);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ resultJson.put("group", groupList);
|
|
|
|
|
+ resultJson.put("result", resultList);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return resultJson;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static JSONObject getAutoComplete(Map<String, Object> parameter) throws IRException {
|
|
|
|
|
+
|
|
|
|
|
+ String adminIp = (String) parameter.get("adminIp");if (adminIp == null) {adminIp = "";}
|
|
|
|
|
+ int adminPort = Integer.parseInt(parameter.get("adminPort").toString());
|
|
|
|
|
+ String searchTerm = (String)parameter.get("searchTerm");if (searchTerm == null) {searchTerm = "";} //Search Word
|
|
|
|
|
+
|
|
|
|
|
+ String searchKeyword = "";
|
|
|
|
|
+ int total = 0;
|
|
|
|
|
+
|
|
|
|
|
+ parameter = new HashMap<String,Object>();
|
|
|
|
|
+
|
|
|
|
|
+ parameter.put("adminIp", adminIp);
|
|
|
|
|
+ parameter.put("adminPort", adminPort);
|
|
|
|
|
+
|
|
|
|
|
+ /////// 자동완성 키워드 검색 ///////////////////////
|
|
|
|
|
+ Query query = new Query();
|
|
|
|
|
+ QuerySet querySet = new QuerySet(1);
|
|
|
|
|
+
|
|
|
|
|
+ Result result = null;
|
|
|
|
|
+ Result[] resultlist = null;
|
|
|
|
|
+ SelectSet[] selectSet = null;
|
|
|
|
|
+ SelectSet[] getselectSet = null;
|
|
|
|
|
+ WhereSet[] whereSet = null;
|
|
|
|
|
+ OrderBySet[] orderBySet = null;
|
|
|
|
|
+ GroupBySet[] groupBySet = null;
|
|
|
|
|
+ CommandSearchRequest cmd = null;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //select
|
|
|
|
|
+ selectSet = new SelectSet[]{
|
|
|
|
|
+ new SelectSet("KEYWORD", Protocol.SelectSet.NONE),
|
|
|
|
|
+ //new SelectSet("CNT", Protocol.SelectSet.NONE)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ //where
|
|
|
|
|
+ whereSet = new WhereSet[]{
|
|
|
|
|
+ new WhereSet(Protocol.WhereSet.OP_BRACE_OPEN),
|
|
|
|
|
+ new WhereSet("IDX_KEYWORD", Protocol.WhereSet.OP_HASALL, searchTerm, 100),
|
|
|
|
|
+ new WhereSet(Protocol.WhereSet.OP_BRACE_CLOSE)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ query.setFrom("AUTOSEARCH");
|
|
|
|
|
+ query.setSelect(selectSet);
|
|
|
|
|
+ query.setWhere(whereSet);
|
|
|
|
|
+ query.setOrderby(orderBySet);
|
|
|
|
|
+ query.setResult(0,9);
|
|
|
|
|
+ query.setSearch(true);
|
|
|
|
|
+ query.setLoggable(false);
|
|
|
|
|
+ query.setDebug(true);
|
|
|
|
|
+ querySet.addQuery(query);
|
|
|
|
|
+ getselectSet = query.getSelectFields();
|
|
|
|
|
+
|
|
|
|
|
+ CommandSearchRequest command = new CommandSearchRequest(adminIp, adminPort);
|
|
|
|
|
+
|
|
|
|
|
+ int returnCode = command.request(querySet);
|
|
|
|
|
+
|
|
|
|
|
+ if (returnCode > 0) {
|
|
|
|
|
+ ResultSet results = command.getResultSet();
|
|
|
|
|
+ resultlist = results.getResultList();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ resultlist = new Result[1];
|
|
|
|
|
+ resultlist[0] = new Result();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, String>> autoList = new ArrayList<Map<String,String>>();
|
|
|
|
|
+ Map<String, Object> queryMap = new HashMap<String, Object>();
|
|
|
|
|
+ Map<String, String> resultMap = new HashMap<String, String>();
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, Object>> parameterList = new ArrayList<Map<String,Object>>();
|
|
|
|
|
+ Map<String, Object> parameterMap = new HashMap<String, Object>();
|
|
|
|
|
+
|
|
|
|
|
+ //받은 파라미터 리스트에 넣기
|
|
|
|
|
+ parameterMap.put("adminIp", adminIp);
|
|
|
|
|
+ parameterMap.put("adminPort", adminPort);
|
|
|
|
|
+ parameterMap.put("searchTerm", searchTerm);
|
|
|
|
|
+ parameterList.add(parameterMap);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (int k = 0; resultlist != null && k < resultlist.length; k++) {
|
|
|
|
|
+ result = resultlist[k];
|
|
|
|
|
+ total = result.getTotalSize();
|
|
|
|
|
+ if (k == 0) {
|
|
|
|
|
+ if (result != null && result.getRealSize() != 0) {
|
|
|
|
|
+ for (int i = 0; i < result.getRealSize(); i++) {
|
|
|
|
|
+ resultMap = new HashMap<String, String>();
|
|
|
|
|
+ for (int j = 0 ; j < result.getNumField(); j++) {
|
|
|
|
|
+ if (j==0) {searchKeyword = new String(result.getResult(i,j));}
|
|
|
|
|
+ resultMap.put(convert2CamelCase(new String(getselectSet[j].getField())), new String(result.getResult(i,j)));
|
|
|
|
|
+ }
|
|
|
|
|
+ autoList.add(resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+
|
|
|
|
|
+ resultJson.put("parameterList", parameterList);
|
|
|
|
|
+ resultJson.put("autoList", autoList);
|
|
|
|
|
+
|
|
|
|
|
+ if (total > 0) {
|
|
|
|
|
+ parameter.put("searchKeyword", searchKeyword);
|
|
|
|
|
+ HashMap<String, Object> searchReturn = benerSearchApi(parameter);
|
|
|
|
|
+ resultJson.put("group", searchReturn.get("group"));
|
|
|
|
|
+ resultJson.put("result", searchReturn.get("result"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return resultJson;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static JSONObject trendKeyword (Map<String, Object> parameter) throws IRException{
|
|
|
|
|
+
|
|
|
|
|
+ Query query = new Query();
|
|
|
|
|
+
|
|
|
|
|
+ QuerySet querySet = new QuerySet(1);
|
|
|
|
|
+
|
|
|
|
|
+ String adminIp = (String) parameter.get("adminIp");if (adminIp == null) {adminIp = "";}
|
|
|
|
|
+ int adminPort = Integer.parseInt(parameter.get("adminPort").toString());
|
|
|
|
|
+
|
|
|
|
|
+ Result result = null;
|
|
|
|
|
+ Result[] resultlist = null;
|
|
|
|
|
+ SelectSet[] getselectSet = null;
|
|
|
|
|
+
|
|
|
|
|
+ List<Map<String, String>> trendList = new ArrayList<Map<String,String>>();
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, String> resultMap = new HashMap<String, String>();
|
|
|
|
|
+
|
|
|
|
|
+ // SelectSet
|
|
|
|
|
+ SelectSet[] selectSet = new SelectSet[]{
|
|
|
|
|
+ new SelectSet("KEYWORD", Protocol.SelectSet.NONE),
|
|
|
|
|
+ new SelectSet("RANKING", Protocol.SelectSet.NONE),
|
|
|
|
|
+ new SelectSet("PREV_RANK", Protocol.SelectSet.NONE)
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ WhereSet[] whereSet = new WhereSet[]{
|
|
|
|
|
+ new WhereSet("IDX_TRENDS_ID", Protocol.WhereSet.OP_HASALL, "trend", 100)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ OrderBySet[] orderbySet = new OrderBySet[] {
|
|
|
|
|
+ new OrderBySet(false, "SORT_RANKING", Protocol.OrderBySet.OP_POSTWEIGHT)
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ query.setFrom("TRENDKEYWORD");
|
|
|
|
|
+ query.setSelect(selectSet);
|
|
|
|
|
+ query.setWhere(whereSet);
|
|
|
|
|
+ query.setOrderby(orderbySet);
|
|
|
|
|
+ query.setResult(0, 29); // 10건만 검색
|
|
|
|
|
+ query.setLoggable(true);
|
|
|
|
|
+ query.setDebug(true);
|
|
|
|
|
+ query.setPrintQuery(false);
|
|
|
|
|
+ querySet.addQuery(query);
|
|
|
|
|
+
|
|
|
|
|
+ getselectSet = query.getSelectFields();
|
|
|
|
|
+ CommandSearchRequest command = new CommandSearchRequest(adminIp, adminPort);
|
|
|
|
|
+
|
|
|
|
|
+ int returnCode = command.request(querySet);
|
|
|
|
|
+
|
|
|
|
|
+ if (returnCode > 0) {
|
|
|
|
|
+ ResultSet results = command.getResultSet();
|
|
|
|
|
+ resultlist = results.getResultList();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ resultlist = new Result[1];
|
|
|
|
|
+ resultlist[0] = new Result();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (int k = 0; resultlist != null && k < resultlist.length; k++) {
|
|
|
|
|
+ result = resultlist[k];
|
|
|
|
|
+ if (k == 0) {
|
|
|
|
|
+ if (result != null && result.getRealSize() != 0) {
|
|
|
|
|
+ for (int i = 0; i < result.getRealSize(); i++) {
|
|
|
|
|
+ resultMap = new HashMap<String, String>();
|
|
|
|
|
+ for (int j = 0 ; j < result.getNumField(); j++) {
|
|
|
|
|
+ resultMap.put(convert2CamelCase(new String(getselectSet[j].getField())) , new String(result.getResult(i,j)));
|
|
|
|
|
+ }
|
|
|
|
|
+ trendList.add(resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject resultJson = new JSONObject();
|
|
|
|
|
+ resultJson.put("trendList", trendList);
|
|
|
|
|
+ System.out.println("result_trend : " + resultJson);
|
|
|
|
|
+
|
|
|
|
|
+ return resultJson;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static String convert2CamelCase(String underScore) {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // '_' 가 나타나지 않으면 이미 camel case 로 가정함.
|
|
|
|
|
+
|
|
|
|
|
+ // 단 첫째문자가 대문자이면 camel case 변환 (전체를 소문자로) 처리가
|
|
|
|
|
+
|
|
|
|
|
+ // 필요하다고 가정함. --> 아래 로직을 수행하면 바뀜
|
|
|
|
|
+
|
|
|
|
|
+ if (underScore.indexOf('_') < 0
|
|
|
|
|
+
|
|
|
|
|
+ && Character.isLowerCase(underScore.charAt(0))) {
|
|
|
|
|
+
|
|
|
|
|
+ return underScore;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ StringBuilder result = new StringBuilder();
|
|
|
|
|
+
|
|
|
|
|
+ boolean nextUpper = false;
|
|
|
|
|
+
|
|
|
|
|
+ int len = underScore.length();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
|
|
+
|
|
|
|
|
+ char currentChar = underScore.charAt(i);
|
|
|
|
|
+
|
|
|
|
|
+ if (currentChar == '_') {
|
|
|
|
|
+
|
|
|
|
|
+ nextUpper = true;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ if (nextUpper) {
|
|
|
|
|
+
|
|
|
|
|
+ result.append(Character.toUpperCase(currentChar));
|
|
|
|
|
+
|
|
|
|
|
+ nextUpper = false;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+
|
|
|
|
|
+ result.append(Character.toLowerCase(currentChar));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result.toString();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|