cancel
Showing results for 
Search instead for 
Did you mean: 

Searching TREX Index through Web Dynpro

Former Member
0 Kudos

Hi experts,

I'm trying to search through my TREX indexes with Web Dynpro. I have found some sources on this website and they seem to work, but when I test my Application, the table I want to fill stays empty.

The strange thing is that the "getNumberResultKeys()" variable is returning a correct value, but that the "ISearchResultList" stays empty.

I'm a newbie in Web Dynpro, so any help will be appreciated!

I wrote the following code:

-



	try{
	
		com.sap.security.api.IUser nwUser = UMFactory.getAuthenticator().getLoggedInUser();
		com.sapportals.portal.security.usermanagement.IUser user;
		user = WPUMFactory.getUserFactory().getEP5User(nwUser);

		ResourceContext resourseContext = new ResourceContext(user); 
		IIndexService indexService = (IIndexService)ResourceFactory.getInstance().getServiceFactory().getService ( "IndexmanagementService");
		IFederatedSearch federatedSearch = (IFederatedSearch)indexService.getObjectInstance("federatedSearchInstance");
		List indexlist=indexService.getActiveIndexes();
		SearchQueryListBuilder sqb = new SearchQueryListBuilder();
		sqb.setSearchTerm("SomeSearchTerm");
		IQueryEntryList qel = sqb.buildSearchQueryList(); 
		ISearchSession session = federatedSearch.searchWithSession(qel, indexlist,resourseContext); 
		ISearchResultList results = session.getSearchResults(1, session.getTotalNumberResultKeys());
		ISearchResultListIterator iter = results.listIterator();
			
		while (iter.hasNext())
		{
		ISearchResult result = iter.next();
		IPrivateDetailView.IPracticeDataElement PracticeData = wdContext.createPracticeDataElement();

								PracticeData.setContentSnippet(result.getContentSnippet());
								PracticeData.setResource(result.getResource().toString());
								
								wdContext.nodePracticeData().addElement(PracticeData);
		}
	
	} catch (ResourceException e1) {
				throw new WDRuntimeException(e1);
	} catch (UserManagementException e2) {
		  		throw new WDRuntimeException(e2);
	} catch (WcmException e3) {
				throw new WDRuntimeException(e3);
	}

-


Thanks in advance for you help,

Edwin

null

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

I found the solution myself.

When I search within the context of an service user, I get the wanted results. There seems to be something wrong with my user credentials.

Thank again for your help!

Former Member
0 Kudos

Hi Armin,

I did try to add some dummy statements and they are written to the table succesfully. This code seems to be the problem:

ISearchResultList results = session.getSearchResults(1, session.getTotalNumberResultKeys());

When I write the value of the variables to the screen, "session.getTotalNumberResultKeys()" has a value of 11, but "session.getSearchResults(1, 11)" has a value of 0.

I don't know what's wrong with the code.

Former Member
0 Kudos

Thanks for your help, but unfortunately the table is still empty after I added your invalidation code.

Anybody got other ideas?

Thanks again...

Former Member
0 Kudos

Ok, then we must try something different.

First, you might to try this: Comment the real searching code out and insert some dummy statements that create and add two node elements (maybe with timestamp) in the action handler. What happens? Is the table displayed correctly? If not, check data binding of table and column editors again. If yes, add some statement that displays the number of results after executing the query.

Armin

Former Member
0 Kudos

My context:

value node - PracticeData

value attribute - Resource

value attribute - ContentSnippet

The results are written to the context here (inside the while - statement):

IPrivateDetailView.IPracticeDataElement PracticeData = wdContext.createPracticeDataElement();
 
								PracticeData.setContentSnippet(result.getContentSnippet());
								PracticeData.setResource(result.getResource().toString());
								
								wdContext.nodePracticeData().addElement(PracticeData);

I created a table with databinding to the value node (and value attributes).

Former Member
0 Kudos

Put the follwing statement before the loop:


wdContext.nodePracticeData().invalidate();

Does this help?

Armin

Former Member
0 Kudos

Describe the context structure and data binding for the table.

Armin