use of org.apache.atlas.model.discovery.SearchParameters in project atlas by apache.
the class DiscoveryREST method searchUsingBasic.
/**
* Retrieve data for the specified fulltext query
*
* @param query Fulltext query
* @param typeName limit the result to only entities of specified type or its sub-types
* @param classification limit the result to only entities tagged with the given classification or or its sub-types
* @param limit limit the result set to only include the specified number of entries
* @param offset start offset of the result set (useful for pagination)
* @return Search results
* @throws AtlasBaseException
* @HTTP 200 On successful FullText lookup with some results, might return an empty list if execution succeeded
* without any results
* @HTTP 400 Invalid fulltext or query parameters
*/
@GET
@Path("/basic")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasSearchResult searchUsingBasic(@QueryParam("query") String query, @QueryParam("typeName") String typeName, @QueryParam("classification") String classification, @QueryParam("excludeDeletedEntities") boolean excludeDeletedEntities, @QueryParam("limit") int limit, @QueryParam("offset") int offset) throws AtlasBaseException {
Servlets.validateQueryParamLength("typeName", typeName);
Servlets.validateQueryParamLength("classification", classification);
if (StringUtils.isNotEmpty(query) && query.length() > maxFullTextQueryLength) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_QUERY_LENGTH, Constants.MAX_FULLTEXT_QUERY_STR_LENGTH);
}
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "DiscoveryREST.searchUsingBasic(" + query + "," + typeName + "," + classification + "," + limit + "," + offset + ")");
}
SearchParameters searchParameters = new SearchParameters();
searchParameters.setTypeName(typeName);
searchParameters.setClassification(classification);
searchParameters.setQuery(query);
searchParameters.setExcludeDeletedEntities(excludeDeletedEntities);
searchParameters.setLimit(limit);
searchParameters.setOffset(offset);
return atlasDiscoveryService.searchWithParameters(searchParameters);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.model.discovery.SearchParameters in project atlas by apache.
the class UserProfileServiceTest method verifyQueryConversionFromJSON.
@Test(dependsOnMethods = { "createsNewProfile", "savesMultipleQueriesForUser" })
public void verifyQueryConversionFromJSON() throws AtlasBaseException {
List<AtlasUserSavedSearch> list = userProfileService.getSavedSearches("first-0");
for (int i = 0; i < max_searches; i++) {
SearchParameters sp = list.get(i).getSearchParameters();
String json = AtlasType.toJson(sp);
assertEquals(AtlasType.toJson(getActualSearchParameters()).replace("\n", "").replace(" ", ""), json);
}
}
use of org.apache.atlas.model.discovery.SearchParameters in project atlas by apache.
the class UserProfileServiceTest method createUserWithSavedQueries.
private void createUserWithSavedQueries(String userName) throws AtlasBaseException {
SearchParameters actualSearchParameter = getActualSearchParameters();
saveQueries(userName, actualSearchParameter);
for (int i = 0; i < max_searches; i++) {
AtlasUserSavedSearch savedSearch = userProfileService.getSavedSearch(userName, getIndexBasedQueryName(i));
assertEquals(savedSearch.getName(), getIndexBasedQueryName(i));
assertEquals(savedSearch.getSearchParameters(), actualSearchParameter);
}
}
use of org.apache.atlas.model.discovery.SearchParameters in project atlas by apache.
the class UserProfileServiceTest method updateSearch.
@Test(dependsOnMethods = { "createsNewProfile", "savesMultipleQueriesForUser", "verifyQueryConversionFromJSON" })
public void updateSearch() throws AtlasBaseException {
final String queryName = getIndexBasedQueryName(0);
String userName = getIndexBasedUserName(0);
AtlasUserSavedSearch expected = userProfileService.getSavedSearch(userName, queryName);
assertNotNull(expected);
SearchParameters sp = expected.getSearchParameters();
sp.setClassification("new-classification");
AtlasUserSavedSearch actual = userProfileService.updateSavedSearch(expected);
assertNotNull(actual);
assertNotNull(actual.getSearchParameters());
assertEquals(actual.getSearchParameters().getClassification(), expected.getSearchParameters().getClassification());
}
Aggregations