use of com.thinkbiganalytics.search.rest.model.SearchResult in project kylo by Teradata.
the class SearchRestController method search.
@GET
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation("Queries a search engine.")
@ApiResponses({ @ApiResponse(code = 200, message = "The search results.", response = SearchResult.class), @ApiResponse(code = 403, message = "Access denied.", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "The search engine is unavailable.", response = RestResponseStatus.class) })
@Nonnull
public Response search(@QueryParam("q") String query, @QueryParam("rows") @DefaultValue("20") Integer rows, @QueryParam("start") @DefaultValue("0") Integer start) {
accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_GLOBAL_SEARCH);
if (searchEngine != null) {
final SearchResult result = searchEngine.search(query, rows, start);
return Response.ok(result).build();
} else {
RestResponseStatus.ResponseStatusBuilder builder = new RestResponseStatus.ResponseStatusBuilder();
builder.message("Search functionality is not available since no search engine is configured.");
return Response.accepted(builder.buildError()).status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of com.thinkbiganalytics.search.rest.model.SearchResult in project kylo by Teradata.
the class SearchFeedMetadataEsIT method verifySearchResultOnUserProperties4.
private void verifySearchResultOnUserProperties4(String term) {
Response response = given(SearchRestController.BASE).when().get("/?q=" + term);
response.then().statusCode(HTTP_OK);
SearchResult searchResult = response.as(SearchResult.class);
Assert.assertEquals("1", searchResult.getTotalHits().toString());
Assert.assertEquals("User properties", searchResult.getSearchResults().get(0).getHighlights().get(0).getKey());
String expected = "<table style='border:1px solid black; border-collapse: collapse;'>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'><font style='font-style:italic'>name</font></td>\n" + "<td style='border:1px solid black;padding: 3px;'><font style='font-style:italic'>value</font></td>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "pk10A common</td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "Aa1000x</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "<font style='font-weight:bold'>or30</font> <font style='font-weight:bold'>organization</font></td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "<font style='font-weight:bold'>Corporate</font> Z5000</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "pv20B utility</td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "Bb2000y S99</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "</table>";
Assert.assertEquals(expected, searchResult.getSearchResults().get(0).getHighlights().get(0).getValue());
}
use of com.thinkbiganalytics.search.rest.model.SearchResult in project kylo by Teradata.
the class SearchFeedMetadataEsIT method verifySearchResultAfterDeletion.
private void verifySearchResultAfterDeletion(String term) {
Response searchResponse = given(SearchRestController.BASE).when().get("/?q=" + term);
searchResponse.then().statusCode(HTTP_OK);
SearchResult searchResult = searchResponse.as(SearchResult.class);
Assert.assertEquals("0", searchResult.getTotalHits().toString());
}
use of com.thinkbiganalytics.search.rest.model.SearchResult in project kylo by Teradata.
the class SearchFeedMetadataEsIT method verifySearchResultOnUserProperties1.
private void verifySearchResultOnUserProperties1(String term) {
Response response = given(SearchRestController.BASE).when().get("/?q=" + term);
response.then().statusCode(HTTP_OK);
SearchResult searchResult = response.as(SearchResult.class);
Assert.assertEquals("1", searchResult.getTotalHits().toString());
Assert.assertEquals("KYLO_FEEDS", searchResult.getSearchResults().get(0).getType().toString());
Assert.assertEquals("pk10A common=Aa1000x\tpv20B utility=Bb2000y S99\tor30 organization=Corporate Z5000", ((FeedMetadataSearchResultData) searchResult.getSearchResults().get(0)).getUserProperties());
Assert.assertEquals(1, searchResult.getSearchResults().get(0).getHighlights().size());
Assert.assertEquals("User properties", searchResult.getSearchResults().get(0).getHighlights().get(0).getKey());
String expected = "<table style='border:1px solid black; border-collapse: collapse;'>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'><font style='font-style:italic'>name</font></td>\n" + "<td style='border:1px solid black;padding: 3px;'><font style='font-style:italic'>value</font></td>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "pk10A common</td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "Aa1000x</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "pv20B utility</td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "<font style='font-weight:bold'>Bb2000y</font> S99</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "<tr>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "or30 organization</td style='border:1px solid black;padding: 3px;'>\n" + "<td style='border:1px solid black;padding: 3px;'>\n" + "Corporate Z5000</td style='border:1px solid black;padding: 3px;'>\n" + "</tr>\n" + "</table>";
Assert.assertEquals(expected, searchResult.getSearchResults().get(0).getHighlights().get(0).getValue());
}
use of com.thinkbiganalytics.search.rest.model.SearchResult in project kylo by Teradata.
the class SearchFeedMetadataEsIT method verifySearchResultOnSystemName1.
private void verifySearchResultOnSystemName1(String term) {
Response response = given(SearchRestController.BASE).when().get("/?q=" + term);
response.then().statusCode(HTTP_OK);
SearchResult searchResult = response.as(SearchResult.class);
Assert.assertEquals("1", searchResult.getTotalHits().toString());
Assert.assertEquals("System name (Kylo)", searchResult.getSearchResults().get(0).getHighlights().get(0).getKey());
Assert.assertEquals("<font style='font-weight:bold'>sample_feed_for_property_search</font>", searchResult.getSearchResults().get(0).getHighlights().get(0).getValue());
}
Aggregations