Search in sources :

Example 16 with SearchResult

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();
    }
}
Also used : SearchResult(com.thinkbiganalytics.search.rest.model.SearchResult) RestResponseStatus(com.thinkbiganalytics.rest.model.RestResponseStatus) Produces(javax.ws.rs.Produces) Nonnull(javax.annotation.Nonnull) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with SearchResult

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());
}
Also used : Response(com.jayway.restassured.response.Response) SearchResult(com.thinkbiganalytics.search.rest.model.SearchResult)

Example 18 with SearchResult

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());
}
Also used : Response(com.jayway.restassured.response.Response) SearchResult(com.thinkbiganalytics.search.rest.model.SearchResult)

Example 19 with SearchResult

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());
}
Also used : Response(com.jayway.restassured.response.Response) SearchResult(com.thinkbiganalytics.search.rest.model.SearchResult)

Example 20 with SearchResult

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());
}
Also used : Response(com.jayway.restassured.response.Response) SearchResult(com.thinkbiganalytics.search.rest.model.SearchResult)

Aggregations

SearchResult (com.thinkbiganalytics.search.rest.model.SearchResult)30 Response (com.jayway.restassured.response.Response)26 SchemaSearchResultData (com.thinkbiganalytics.search.rest.model.SchemaSearchResultData)3 SearchResultData (com.thinkbiganalytics.search.rest.model.SearchResultData)3 TableSearchResultData (com.thinkbiganalytics.search.rest.model.TableSearchResultData)3 UnknownTypeSearchResultData (com.thinkbiganalytics.search.rest.model.UnknownTypeSearchResultData)3 ArrayList (java.util.ArrayList)3 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)2 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)2 CategoryMetadataSearchResultData (com.thinkbiganalytics.search.rest.model.CategoryMetadataSearchResultData)2 FeedMetadataSearchResultData (com.thinkbiganalytics.search.rest.model.FeedMetadataSearchResultData)2 RestResponseStatus (com.thinkbiganalytics.rest.model.RestResponseStatus)1 ElasticSearchRestSearchHit (com.thinkbiganalytics.search.rest.model.es.ElasticSearchRestSearchHit)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 Nonnull (javax.annotation.Nonnull)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 SolrDocument (org.apache.solr.common.SolrDocument)1