Package com.tistory.devyongsik.crescent.collection.entity

Examples of com.tistory.devyongsik.crescent.collection.entity.CrescentCollection


  private void indexingTestData() {
   
    Handler handler = new JsonDataHandler();
    IndexingRequestForm indexingRequestForm = handler.handledData(bulkIndexingTestText);
    CrescentCollections crescentCollections = collectionHandler.getCrescentCollections();
    CrescentCollection collection = crescentCollections.getCrescentCollection("sample");
   
    String message = executor.indexing(collection, indexingRequestForm);

    System.out.println("indexing result message : " + message);
  }
View Full Code Here


   
    //collection name
    CrescentCollectionHandler collectionHandler
    = SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class);
   
    CrescentCollection collection = collectionHandler.getCrescentCollections()
                          .getCrescentCollection(searchRequest.getCollectionName());
   
    if(collection == null) {
      throw new CrescentInvalidRequestException("Wrong Collection Name : " + searchRequest.getCollectionName());
    }
   
   
    //request search field
    if(searchRequest.getSearchField() != null) {
      String[] requestSearchFieldNames = searchRequest.getSearchField().split(",");
     
      if(requestSearchFieldNames != null && requestSearchFieldNames[0].length() > 0) {
        for(String requestFieldName : requestSearchFieldNames) {
          if(!collection.getCrescentFieldByName().containsKey(requestFieldName)) {
            throw new CrescentInvalidRequestException("Wrong Search Field Name : " + searchRequest.getSearchField());
          }
        }
      }
    }
   
    //page num
    if(searchRequest.getPageNum() != null) {
      if(!StringUtil.isNumeric(searchRequest.getPageNum())) {
        throw new CrescentInvalidRequestException("Page_Num parameter value is must positive number: " + searchRequest.getPageNum());
      }
    }
   
    //request sort field
    String sortQueryString = searchRequest.getSort();
    if(sortQueryString == null || "".equals(sortQueryString) || "null".equals(sortQueryString)) {
      //nothing
    } else {
 
      String[] parts = sortQueryString.split(",");
      if(parts.length == 0) {
        throw new CrescentInvalidRequestException("Wrong Sort Field Name : " + sortQueryString);
      }
 
      for(int i = 0; i < parts.length; i++) {
        String part = parts[i].trim(); //part = field desc
       
        int idx = part.indexOf( ' ' );
       
        if(idx <= 0) {
          throw new CrescentInvalidRequestException("No Order Condition (DESC/ASC) : " + sortQueryString);
        }
       
        part = part.substring( 0, idx ).trim(); //part = field
        Map<String, CrescentCollectionField> collectionFields = collection.getCrescentFieldByName();
       
        CrescentCollectionField f = collectionFields.get(part);
       
        if(f == null) throw new CrescentInvalidRequestException("요청된 필드가 존재하지 않습니다. ["+part+"]");
        if(f.isAnalyze()) throw new CrescentInvalidRequestException("Analyze 된 필드는 Sort가 불가능합니다. ["+part+"]");
View Full Code Here

       
        CrescentFastVectorHighlighter highlighter = new CrescentFastVectorHighlighter();
       
        CrescentCollectionHandler collectionHandler
        = SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class);
        CrescentCollection collection = collectionHandler.getCrescentCollections().getCrescentCollection(csrw.getCollectionName());
       
        //int docnum = 0;
        for(int i = startOffset; i < endOffset; i++) {
         
          Map<String,String> resultMap = new HashMap<String, String>();
         
          for(CrescentCollectionField field : collection.getFields()) {
            String value = null;
               
            if(field.isStore() && !field.isNumeric()) {
             
              //필드별 결과를 가져온다.
View Full Code Here

    String searchModeAnalyzerType = request.getParameter("searchModeAnalyzerType");
   
    String indexingModeAnalyzerConstArgs = request.getParameter("indexingModeAnalyzerConstArgs");
    String searchModeAnalyzerConstArgs = request.getParameter("searchModeAnalyzerConstArgs");
   
    CrescentCollection selectedCollection = crescentCollections.getCrescentCollection(selectedCollectionName);
   
    List<CrescentAnalyzerHolder> analyzerHolderList = new ArrayList<CrescentAnalyzerHolder>();
    CrescentAnalyzerHolder indexingModeAnalyzerHolder = new CrescentAnalyzerHolder();
    indexingModeAnalyzerHolder.setClassName(indexingModeAnalyzer);
    indexingModeAnalyzerHolder.setConstructorArgs(indexingModeAnalyzerConstArgs);
    indexingModeAnalyzerHolder.setType(indexingModeAnalyzerType);
    analyzerHolderList.add(indexingModeAnalyzerHolder);
   
    CrescentAnalyzerHolder searchModeAnalyzerHolder = new CrescentAnalyzerHolder();
    searchModeAnalyzerHolder.setClassName(searchModeAnalyzer);
    searchModeAnalyzerHolder.setConstructorArgs(searchModeAnalyzerConstArgs);
    searchModeAnalyzerHolder.setType(searchModeAnalyzerType);
    analyzerHolderList.add(searchModeAnalyzerHolder);
   
    selectedCollection.setAnalyzers(analyzerHolderList);
   
    selectedCollection.setSearcherReloadScheduleMin(StringUtils.defaultIfEmpty(request.getParameter("searcherReloadScheduleMin"), "10"));

    if(logger.isDebugEnabled()) {
      logger.debug("analyzer : {} ", request.getParameter("analyzer"));
      logger.debug("collection Name : {} ", request.getParameter("collectionName"));
      logger.debug("indexing Directory : {} ", request.getParameter("indexingDirectory"));
      logger.debug("searcher reload schedule min : {} ", request.getParameter("searcherReloadScheduleMin"));
      logger.debug("indexingModeAnalyzer : {} ", request.getParameter("indexingModeAnalyzer"));
      logger.debug("searchModeAnalyzer : {} ", request.getParameter("searchModeAnalyzer"));
      logger.debug("indexingModeAnalyzerType : {} ", request.getParameter("indexingModeAnalyzerType"));
      logger.debug("searchModeAnalyzerType : {} ", request.getParameter("searchModeAnalyzerType"));
      logger.debug("indexingModeAnalyzerConstArgs : {} ", request.getParameter("indexingModeAnalyzerConstArgs"));
      logger.debug("searchModeAnalyzerConstArgs : {} ", request.getParameter("searchModeAnalyzerConstArgs"));
    }

    List<CrescentCollectionField> crescentCollectionFieldList = selectedCollection.getFields();

    //추가되는 필드명을 모은다.
    @SuppressWarnings("unchecked")
    Enumeration<String> enumeration = request.getParameterNames();
    List<String> addFieldNameList = new ArrayList<String>();
    while(enumeration.hasMoreElements()) {
      String paramValue = enumeration.nextElement();
      if(paramValue.endsWith("fieldName")) {
        addFieldNameList.add(paramValue.substring(0, paramValue.lastIndexOf("-")));
      }
    }

    logger.debug("add field name list : {}", addFieldNameList);

    for(String fieldName :addFieldNameList) {
      CrescentCollectionField crescentField = new CrescentCollectionField();
      crescentField.setName(fieldName);
     
      if(!crescentCollectionFieldList.contains(crescentField)) {
        crescentCollectionFieldList.add(crescentField);
      }
    }
       
    for(CrescentCollectionField crescentField : crescentCollectionFieldList) {

      crescentField.setAnalyze("on".equals(request.getParameter(crescentField.getName()+"-analyze")) ? true : false);
      crescentField.setIndex("on".equals(request.getParameter(crescentField.getName()+"-index")) ? true : false);
      crescentField.setMust("on".equals(request.getParameter(crescentField.getName()+"-must")) ? true : false);
      crescentField.setStore("on".equals(request.getParameter(crescentField.getName()+"-store")) ? true : false);
      crescentField.setTermoffset("on".equals(request.getParameter(crescentField.getName()+"-termoffset")) ? true : false);
      crescentField.setTermposition("on".equals(request.getParameter(crescentField.getName()+"-termposition")) ? true : false);
      crescentField.setTermvector("on".equals(request.getParameter(crescentField.getName()+"-termvector")) ? true : false);
      crescentField.setRemoveHtmlTag("on".equals(request.getParameter(crescentField.getName()+"-removeHtmlTag")) ? true : false);

      crescentField.setBoost(Float.parseFloat(StringUtils.defaultString(request.getParameter(crescentField.getName()+"-boost"), "0")));
      crescentField.setType(StringUtils.defaultString(request.getParameter(crescentField.getName()+"-type"), "STRING"));


      //sort field 처리
      if("on".equals(request.getParameter(crescentField.getName()+"-sortField"))) {
        CrescentSortField sortField = new CrescentSortField();
        sortField.setSource(crescentField.getName());
        sortField.setDest(crescentField.getName()+"_sort");

        if(selectedCollection.getSortFields().contains(sortField)) {
          //Nothing
        } else {
          selectedCollection.getSortFields().add(sortField);
        }
      }

      //default search field 처리
      if("on".equals(request.getParameter(crescentField.getName()+"-defaultSearchField"))) {
        CrescentDefaultSearchField defaultSearchField = new CrescentDefaultSearchField();
        defaultSearchField.setName(crescentField.getName());

        if(selectedCollection.getDefaultSearchFields().contains(defaultSearchField)) {
          //Nothing
        } else {
          selectedCollection.getDefaultSearchFields().add(defaultSearchField);
        }
      }

      if(logger.isDebugEnabled()) {
        logger.debug("crescentField Name {} = {}", crescentField.getName(), "sortField : " + request.getParameter(crescentField.getName()+"-sortField"));
View Full Code Here

   
    String selectedCollectionName = request.getParameter("collectionName");

    logger.debug("selectedCollectionName : " + selectedCollectionName);
   
    CrescentCollection newCollection = new CrescentCollection();
    newCollection.setName(selectedCollectionName);
    newCollection.setIndexingDirectory(request.getParameter("indexingDirectory"));
   
    newCollection.setSearcherReloadScheduleMin(StringUtils.defaultIfEmpty(request.getParameter("searcherReloadScheduleMin"), "10"));

    String indexingModeAnalyzer = request.getParameter("indexingModeAnalyzer");
    String searchModeAnalyzer = request.getParameter("searchModeAnalyzer");
   
    String indexingModeAnalyzerType = request.getParameter("indexingModeAnalyzerType");
    String searchModelAnalyzerType = request.getParameter("searchModeAnalyzerType");
   
    String indexingModeAnalyzerConstArgs = request.getParameter("indexingModeAnalyzerConstArgs");
    String searchModeAnalyzerConstArgs = request.getParameter("searchModeAnalyzerConstArgs");
   
    List<CrescentAnalyzerHolder> analyzerHolderList = new ArrayList<CrescentAnalyzerHolder>();
    CrescentAnalyzerHolder indexingModeAnalyzerHolder = new CrescentAnalyzerHolder();
    indexingModeAnalyzerHolder.setClassName(indexingModeAnalyzer);
    indexingModeAnalyzerHolder.setConstructorArgs(indexingModeAnalyzerConstArgs);
    indexingModeAnalyzerHolder.setType(indexingModeAnalyzerType);
    analyzerHolderList.add(indexingModeAnalyzerHolder);
   
    CrescentAnalyzerHolder searchModeAnalyzerHolder = new CrescentAnalyzerHolder();
    searchModeAnalyzerHolder.setClassName(searchModeAnalyzer);
    searchModeAnalyzerHolder.setConstructorArgs(searchModeAnalyzerConstArgs);
    searchModeAnalyzerHolder.setType(searchModelAnalyzerType);
    analyzerHolderList.add(searchModeAnalyzerHolder);
   
    if(logger.isDebugEnabled()) {
      logger.debug("analyzer : {} ", request.getParameter("analyzer"));
      logger.debug("collection Name : {} ", request.getParameter("collectionName"));
      logger.debug("indexing Directory : {} ", request.getParameter("indexingDirectory"));
      logger.debug("searcher reload schedule min : {} ", request.getParameter("searcherReloadScheduleMin"));
      logger.debug("indexingModeAnalyzer : {} ", request.getParameter("indexingModeAnalyzer"));
      logger.debug("searchModeAnalyzer : {} ", request.getParameter("searchModeAnalyzer"));
      logger.debug("indexingModeAnalyzerType : {} ", request.getParameter("indexingModeAnalyzerType"));
      logger.debug("searchModelAnalyzerType : {} ", request.getParameter("searchModelAnalyzerType"));
      logger.debug("indexingModeAnalyzerConstArgs : {} ", request.getParameter("indexingModeAnalyzerConstArgs"));
      logger.debug("searchModeAnalyzerConstArgs : {} ", request.getParameter("searchModeAnalyzerConstArgs"));
    }

    //필드들을 걸러낸다.
    @SuppressWarnings("unchecked")
    Enumeration<String> enumeration = (Enumeration<String>)request.getParameterNames();
    List<String> fieldNameList = new ArrayList<String>();
    while(enumeration.hasMoreElements()) {
      String paramName = enumeration.nextElement();

      if(paramName.endsWith("-fieldName")) { //필수값
        String fieldName = paramName.split("-")[0];
        fieldNameList.add(fieldName);
      }
    }
   
    List<CrescentCollectionField> newCollectionFieldList = new ArrayList<CrescentCollectionField>();
    List<CrescentSortField> sortFieldList = new ArrayList<CrescentSortField>();
    List<CrescentDefaultSearchField> defaultSearchFieldList = new ArrayList<CrescentDefaultSearchField>();
   
    for(String fieldName : fieldNameList) {
      CrescentCollectionField newCollectionField = new CrescentCollectionField();
     
      newCollectionField.setName(fieldName);
      newCollectionField.setAnalyze("on".equals(request.getParameter(fieldName+"-analyze")) ? true : false);
      newCollectionField.setIndex("on".equals(request.getParameter(fieldName+"-index")) ? true : false);
      newCollectionField.setMust("on".equals(request.getParameter(fieldName+"-must")) ? true : false);
      newCollectionField.setStore("on".equals(request.getParameter(fieldName+"-store")) ? true : false);
      newCollectionField.setTermoffset("on".equals(request.getParameter(fieldName+"-termoffset")) ? true : false);
      newCollectionField.setTermposition("on".equals(request.getParameter(fieldName+"-termposition")) ? true : false);
      newCollectionField.setTermvector("on".equals(request.getParameter(fieldName+"-termvector")) ? true : false);

      //System.out.println("DDDDDDDDDDDDDD : " + request.getParameter(fieldName+"-boost"));
     
      newCollectionField.setBoost(Float.parseFloat(StringUtils.defaultIfEmpty(request.getParameter(fieldName+"-boost"), "0")));
      newCollectionField.setType(StringUtils.defaultString(request.getParameter(fieldName+"-type"), "STRING"));

      newCollectionFieldList.add(newCollectionField);
     
      //sort field 처리     
      if("on".equals(request.getParameter(fieldName+"-sortField"))) {
        CrescentSortField sortField = new CrescentSortField();
        sortField.setSource(fieldName);
        sortField.setDest(fieldName+"_sort");

        sortFieldList.add(sortField);
      }
     
      //default search field 처리
      if("on".equals(request.getParameter(fieldName+"-defaultSearchField"))) {
        CrescentDefaultSearchField defaultSearchField = new CrescentDefaultSearchField();
        defaultSearchField.setName(fieldName);
        defaultSearchFieldList.add(defaultSearchField);
      }
     

      if(logger.isDebugEnabled()) {
        logger.debug("crescentField Name {} = {}", fieldName, "sortField : " + request.getParameter(fieldName+"-sortField"));
        logger.debug("crescentField Name {} = {}", fieldName, "defaultSearchField : "+ request.getParameter(fieldName+"-defaultSearchField"));
      }

      if(logger.isDebugEnabled()) {
        logger.debug("crescentField Name {} = {}", fieldName, "analyze : " + request.getParameter(fieldName+"-analyze"));
        logger.debug("crescentField Name {} = {}", fieldName, "index : " + request.getParameter(fieldName+"-index"));
        logger.debug("crescentField Name {} = {}", fieldName, "must : " + request.getParameter(fieldName+"-must"));
        logger.debug("crescentField Name {} = {}", fieldName, "store : " + request.getParameter(fieldName+"-store"));
        logger.debug("crescentField Name {} = {}", fieldName, "termoffset : " + request.getParameter(fieldName+"-termoffset"));
        logger.debug("crescentField Name {} = {}", fieldName, "termposition : " + request.getParameter(fieldName+"-termposition"));
        logger.debug("crescentField Name {} = {}", fieldName, "termvector : " + request.getParameter(fieldName+"-termvector"));
        logger.debug("crescentField Name {} = {}", fieldName, "boost : " + request.getParameter(fieldName+"-boost"));
        logger.debug("crescentField Name {} = {}", fieldName, "type : " + request.getParameter(fieldName+"-type"));
      }
    }
   
    newCollection.setSortFields(sortFieldList);
    newCollection.setDefaultSearchFields(defaultSearchFieldList);
    newCollection.setFields(newCollectionFieldList);
    newCollection.setAnalyzers(analyzerHolderList);
   
    collectionHandler.getCrescentCollections().getCrescentCollections().add(newCollection);
    collectionHandler.writeToXML();
    collectionHandler.reloadCollectionsXML();
   
View Full Code Here

      IndexingRequestForm indexingRequestForm = handler.handledData(text.toString());
     
//      CrescentCollectionHandler collectionHandler
//        = SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class);
     
      CrescentCollection collection = collectionHandler.getCrescentCollections().getCrescentCollection(collectionName);
      //CrescentIndexerExecutor executor = new CrescentIndexerExecutor(collection, indexingRequestForm);
     
      String message = crescentIndexerExecutor.indexing(collection, indexingRequestForm);
     
      Writer writer = null;
View Full Code Here

 
  @Override
  public List<MorphToken> getTokens(String keyword, boolean isIndexingMode, String collectionName) throws IOException {
    StringReader reader = new StringReader(keyword);
   
    CrescentCollection crescentCollection = collectionHandler.getCrescentCollections().getCrescentCollection(collectionName);
    Analyzer analyzer = null;
   
    if(isIndexingMode) {
      analyzer = crescentCollection.getIndexingModeAnalyzer();
    } else {
      analyzer = crescentCollection.getSearchModeAnalyzer();
    }
   
    TokenStream stream = analyzer.tokenStream("dummy", reader);
    stream.reset();
   
View Full Code Here

        for (CrescentCollection crescentCollection : collectionHandler.getCrescentCollections().getCrescentCollections()) {
            collectionNames.add(crescentCollection.getName());
        }

        String selectCollectionName = collectionNames.get(0);
        CrescentCollection selectCollection = collectionHandler
                                                    .getCrescentCollections()
                                                    .getCrescentCollection(selectCollectionName);

    IndexInfo indexInfo = indexFileManageService.getIndexInfo(selectCollection);
View Full Code Here

  @RequestMapping("/collectionUpdate")
  public ModelAndView collectionUpdate(HttpServletRequest request, HttpServletResponse response) throws Exception {

    CrescentCollections crescentCollections = collectionHandler.getCrescentCollections();
   
    CrescentCollection selectedCollection = collectionManageService.updateCollectionInfo(request);
   
   
    ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("crescentCollectionList", crescentCollections.getCrescentCollections());
    modelAndView.addObject("selectedCollection", crescentCollections.getCrescentCollection(selectedCollection.getName()));
    modelAndView.addObject("selectedCollectionName", selectedCollection.getName());
   
    modelAndView.setViewName("/admin/collectionManageMain");
   
   
    return modelAndView;
View Full Code Here

  }
 
  @RequestMapping("/collectionAdd")
  public ModelAndView collectionAdd(HttpServletRequest request, HttpServletResponse response) throws Exception {
   
    CrescentCollection selectedCollection = collectionManageService.addCollectionInfo(request);
   
//    CrescentCollectionHandler collectionHandler
//    = SpringApplicationContext.getBean("crescentCollectionHandler", CrescentCollectionHandler.class);
   
    CrescentCollections crescentCollections = collectionHandler.getCrescentCollections();
 
 
    ModelAndView modelAndView = new ModelAndView();
    //modelAndView.addObject("crescentCollections", crescentCollections);
    modelAndView.addObject("crescentCollectionList", crescentCollections.getCrescentCollections());
    modelAndView.addObject("selectedCollection", crescentCollections.getCrescentCollection(selectedCollection.getName()));
    modelAndView.addObject("selectedCollectionName", selectedCollection.getName());
   
   
    modelAndView.setViewName("/admin/collectionManageMain");
   
   
View Full Code Here

TOP

Related Classes of com.tistory.devyongsik.crescent.collection.entity.CrescentCollection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.