Skip to Content
0
Former Member
Jul 22, 2005 at 08:03 AM

Incorrect search result from customized search

19 Views

Dear all,

I'm now doing a customized search in EP 5.0.

I simply pass in the search word into the search object and do the query.

However, the searched result is much less than the original search engine of EP.

Besides, when I do the search with chinese character, there return no result in the customized search, but return many record from the original search engine.

Do any one can help? Here attached the code that I used.

		try{
		  IResourceContext resourceContext = ResourceFactory.getInstance().getServiceContext();
		  IIndexService indexService =
(IIndexService)ResourceFactory.getInstance()
.getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);

		  IFederatedSearch federatedSearch = 
(IFederatedSearch)indexService.getObjectInstance
(IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);
		
		  // search under a RID
		  RID folderRid = null;
		  if (selFolder.equals("")){
			folderRid = RID.getRID(defaultFolder);
		  }else{
			folderRid = RID.getRID(selFolder);
		  }
		  	
		  IResourceFactory resFactory = ResourceFactory.getInstance();
		  ICollection myCollection = (ICollection) resFactory.getResource(folderRid, resourceContext);

		  // create query object
		  IQueryEntryList queryEntryList = federatedSearch.getNewQueryEntryList();

		  IQueryEntry searchTerm = null;
		  if (!selDocument.equals("")){
			  //create search criteria (search term)
			  searchTerm = federatedSearch.getNewQueryEntry();
			  searchTerm.setRowType(IQueryEntry.ROW_TYPE_TERM);
			  searchTerm.setTermAction(IQueryEntry.TERM_ACTION_LINGUISTIC);
			  searchTerm.setTermWeight(1.0F);
			  searchTerm.setValue(selDocument);
		  }

		  
		  //add criteria to list
		  queryEntryList.add(searchTerm);


		  // perform search			
		  try{
				ISearchSession results = null;
				results = federatedSearch.searchWithSession(queryEntryList, myCollection, resourceContext);
				
				//resultTotal = results.getNumberResultKeys();
				resultTotal = results.getTotalNumberResultKeys();
				if (resultTotal > 0){
					if (resultTotal == 1){
						state = SEARCHED_WITH_ONLY_ONE_RESULT_STATE;
					}else{
						state = SEARCHED_WITH_RESULT_STATE;
					}
					
					//mark the status for drawing result list
					searchResults = results;
					resultFrom = 1;
					if (resultTotal > RESULT_PER_PAGE)
						resultTo = RESULT_PER_PAGE;
					else
						resultTo = resultTotal;
				}else{
					//search without result return
					state = SEARCHED_WITHOUT_RESULT_STATE;
				}
		  }catch (WcmException e){
				state = ERROR_STATE;
				errorMsg = e.getMessage();
		  }
		}catch (WcmException e){
		  e.printStackTrace();
		}

Thanks a lot