You can use the Mindbreeze web client or the SDK interface for the search in order to embed search results in your application.
The Mindbreeze SearchService offers access to search results, their properties, facets and did-you-mean suggestions. The search are of course authorised and different authentication methods are available. The Mindbreeze client service makes the SearchService available. This means that the configuration of the client service also influences the SDK interface.
The SDK example contains a JSP application that uses the SearchService. To run the application, start the Apache Tomcat server in Eclipse.
Open the test URL http://localhost:8080/search/search.jsp in a browser and start the search.
In the file search.jsp
a SearchRequest
is built up which is then send to the SearchService. A minimal SearchRequest
can look as follows:
QueryExpr query = QueryExpr.newBuilder().setKind(QueryExpr.Kind.EXPR_UNPARSED).setUnparsedExpr ("user query").build(); SearchRequest searchRequest = SearchRequest.newBuilder() .setRankingStrategy(RankingStrategy.RANK) .setDetailLimit(DetailLimit.CONTENT) .setUserQuery(query) .addView(View.newBuilder() .setId("view") .setCount(10) .setRankingStrategy(mindbreeze.query.ViewProtos.View.RankingStrategy.RELEVANCE) ) .build();
The SearchRequest
is carried out with SearchServiceClient().performSearch
. The method performSearch
delivers a SearchResponse object as a result, which contains the results, facets and did-you-mean suggestions.
SearchResponse searchResponse = new SearchServiceClient(endpoint) .performSearch(request.getServletContext(), searchRequest);
For each view defined by the search the SearchResponse
object contains a ResultSet
. Each ResultSet
contains Result
objects for the results. The properties of the results are accessible with getPropertyList()
. You can display the title and content as follows:
ResultSet resultSet = searchResponse.getResultSet(0); <% for (Result result : resultSet.getResultList()) {%> <% Map<String, NamedValue> properties = PropertyHelper.asMap(result.getPropertyList()); %> <div class="result"> <h2><%= PropertyHelper.getSampleText(properties.get("title")) %></h2> <p> <%= PropertyHelper.getSampleText(properties.get("content")) %> </p> </div> <% } %>
Authentication possibilities
There are 3 user login possibilities available: Kerberos, SAML and Trusted Peer Authentication. Please see the respective handbooks for the configuration of the individual variations.
For Kerberos and SAML ticket and assertion is used directly for the authentication of a user.
Trusted Peer Authentication conversely allows a service user to login who can then specify which user is logged in. Therefore this variation is necessary if a service cannot forward tickets/assertions. Here you have to be careful with the confidential handling of the used certificates so that no user can see another user’s data. The document Trusted Peer Authentication offers information on this.
Download
Access the Mindbreeze InSpire SDK download area.