cancel
Showing results for 
Search instead for 
Did you mean: 

Search iView for Knowledge Management

former_member225470
Participant
0 Kudos

SDN Behind The Scenes - How We Developed A New Search Interface: https://www.sdn.sap.com/irj/.../com.sap.sdn.codesamples.search

Hello,

I have two problems with the code-example (see the link for the code above) for a new search-iview.

1. Problem:

I created the search-iview with the same code from the example and it runs in the same way like the example on SAP Developer Network excepted the search with the wildcard "*".

By this search I only get a blank site.

2. Problem:

I want to expand the functionality of the search: The search should return documents, with an until yet not readed by the user. (property meta data: readbyme = false)

I added code between the to lines to the original code (see below).

After testing the code, the search result doesn´t work in wanted way.

Can somebody help me to realise an expanded search after certain document properties?

Best regards,

Arnold Gallemann

private ISearchResultList performSearch(String searchString, String indexId, int maxRecordsReturned) throws ResourceException, WcmException{

//Get the resource context

IResourceContext resourceContext = (IResourceContext)new ResourceContext(this.loggedOnUser);

//Get the global service IIndexService

IIndexService indexService = (IIndexService)ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);

//Get an IIndex object

IIndex index = indexService.getIndex(indexId);

//Cast the IIndex object into a ISearchIndex object

ISearchIndex searchIndex = (ISearchIndex)index;

//Get and IQueryEntryList object

IQueryEntryList queryEntryList = searchIndex.getNewQueryEntryList();

//Get an IQueryEntry object

IQueryEntry queryEntry = searchIndex.getNewQueryEntry();

//Set the row type

queryEntry.setRowType(IQueryEntry.ROW_TYPE_TERM);

//Set the TermAction

queryEntry.setTermAction(IQueryEntry.TERM_ACTION_EXACT);

//Set the Term weight

queryEntry.setTermWeight(1.0F);

//Set the query string

queryEntry.setValue(searchString);

//----

-


//Added source code:

//Set Property Meta Data readbyme

queryEntry.setRowType(IQueryEntry.ROW_TYPE_ATTRIBUTE);

IPropertyName glesen = (IPropertyName)new PropertyName("http://sapportals.com/xmlns/cm/acc_stat", "readbyme");

queryEntry.setPropertyName(glesen);

queryEntry.setPropertyType(IQueryEntry.PROPERTY_TYPE_STRING);

queryEntry.setValue("true");

//----

-


*/

//Add the queryEntry to the queryEntryList

queryEntryList.add(queryEntry);

//Execute the query

ISearchResultList results = searchIndex.executeQuery(queryEntryList, resourceContext, 100);

return results;

}

Accepted Solutions (1)

Accepted Solutions (1)

thilo_brandt
Employee
Employee
0 Kudos

Hi Arnold,

ad 1) * Search means that all documents from the selected indexes are returned. Please check in the TREX Monitor, how many documents are already indexed.

ad 2) To add an IPropertyName to a specifix search you have to create an TREX conmpliant IQueryList object. This can be done manually by adding the correct sequence of IQueryEntry objects to the list. Or more simple: Just use the SearchQueryBuilder class to generate and validate a TREX compliant query object:

com.sapportals.wcm.control.util.search.SearchQueryBuilder sb = new SearchQueryBuilder();

sb.setSearchTerm("SearchTerm");

sb.setSelectedCustomProps("{<prop-namespace>}propertyid");

:

:

IQueryEntryList list = sb.buildSearchQueryEntry();

Best regards,

Thilo

Former Member
0 Kudos

Hi Thilo,

we have found a not comprehensibly behavior in different Search iViews in the portal on the same index:

If we search with the wildcard "", one iView shows all documents from the index. The other iView found no document. It only works with an additional letter (e. g. searchstring "t" returns all documents starting with a "t").

Do you have an advice for these different behavior of the two iViews on the same portal?

Best regards,

Gerhard

Answers (0)