on 07-26-2007 3:40 PM
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
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your help, but unfortunately the table is still empty after I added your invalidation code.
Anybody got other ideas?
Thanks again...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Describe the context structure and data binding for the table.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.