cancel
Showing results for 
Search instead for 
Did you mean: 

Empty SearchResultList -- using KM API in WD Java

Amey-Mogare
Contributor
0 Kudos

Hi All,

I am implementing KM Search using Web Dynpro for Java.

I have created an index in Portal KM and assigned a folder as datasource to it. But when I am searching it through Web Dynpro application, I am not able to view any results.

Following is the code I have written:-


//1. Get User ResourceContext
wdClientUser = WDClientUser.getCurrentUser();
sapUser = wdClientUser.getSAPUser();
ep5User = WPUMFactory.getUserFactory().getEP5User(sapUser);
resourceContext = new ResourceContext(ep5User);
			
//2. Get an object of index management service
indexService = (IIndexService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);
		
//3. Get instance of federated search
federatedSearch = (IFederatedSearch) indexService.getObjectInstance(IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);
indexList = indexService.getActiveIndexes();
			
//4. Build Query Object
sqlBuilder = new SearchQueryListBuilder();
sqlBuilder.setSearchTerm(query);
qeList = sqlBuilder.buildSearchQueryList();
			
//5. For Searching executions
ISearchSession session = federatedSearch.searchWithSession(qeList,indexList,resourceContext);
ISearchResultList results = session.getSearchResults(1, session.getTotalNumberResultKeys());

ISearchResultListIterator iter = results.listIterator();
		
//6. Finding individual resources
int count = 0;
ISearchResult result = null;
IResource nresource = null;
			
while(iter.hasNext()){
			
	result = iter.next();
	nresource = result.getResource();
				
}

Is it something that we can not implement KM API throught Web Dynpro Java view?

What could be reason that API is not able to find any results?

Thanks and regards,

Amey Mogare

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

APi can be very well use no problem with that as I have used km serach in web dynpro before successfully..Code also looks good at first look.

Pls check @portal if the index is working as expected on folder.

Regards,

Ashok

Amey-Mogare
Contributor
0 Kudos

Hi Ashok,

Yes, u were correct. I didnt configured my Index at portal correctly and so was the issue.

Now I am able to get search-results.

Thank you.

Now can you tell me about what all parameters I could get from these search results?

I mean I tried Standard Search URL of portal :-

http://serverHost:serverPort/irj/servlet/prt/portal/prteventname/HtmlbEvent/prtroot/com.sap.km.cm.ba...

It shows various other details along with what we get using KM API.

for example: search relevance percentage, seached text etc

How do I get these parameters from API?

Thanks and regards,

Amey Mogare

0 Kudos

Any luck with the relevance and so on? I got the same "problem" right now too...

Amey-Mogare
Contributor
0 Kudos

Hello Constantin,

I dont remember & dont have access to this application as I moved to different project.

I am sorry, about not able to help you with this.

But as far as I remember, in last, I could not able to retrieve these details like relevance etc.

Idea was dropped later on by customer.

0 Kudos

Well, the solution is pretty simple, i just overlooked it unfortunatly:

ISearchResult.getRankValue()

Which returns a float value like 0.71351 for 71.4%

Answers (1)

Answers (1)

Former Member
0 Kudos

Check for presmissions on the index and the folders.

Is your WD app using authentication=true parameter?