cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect search result from customized search

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hey Sem,

Your search is going over a specific RID, which means specific Repository.

If you are refering to the global search of the portal than it searches on all Repositories.

Can you please elaborate this issue?

Former Member
0 Kudos

Hi Roy,

Thanks a lot for your reply.

Yes, I am doing a search under a specific RID. I've check that for the standard search provided from the EP also. For the standard search, it can return lot of result under the specific RID. But for the customized search, it can only return a little result under the specific RID.

Regards

Sam