use of org.apache.atlas.model.discovery.AtlasQuickSearchResult in project atlas by apache.
the class DiscoveryExample method quickSearch.
public void quickSearch(String searchString) {
try {
AtlasQuickSearchResult result = client.quickSearch(searchString, SampleAppConstants.TABLE_TYPE, false, 2, 0);
List<AtlasEntityHeader> entities = result != null && result.getSearchResults() != null ? result.getSearchResults().getEntities() : null;
int resultCount = entities == null ? 0 : entities.size();
SampleApp.log("Quick search: query-string=" + searchString);
SampleApp.log(" result count: " + resultCount);
for (int i = 0; i < resultCount; i++) {
SampleApp.log(" result # " + (i + 1) + ": " + entities.get(i));
}
} catch (AtlasServiceException e) {
e.printStackTrace();
}
}
use of org.apache.atlas.model.discovery.AtlasQuickSearchResult in project atlas by apache.
the class AtlasDiscoveryServiceTest method specialCharQuickSearchAssertQFName.
@Test(dataProvider = "specialCharSearchQFName")
public void specialCharQuickSearchAssertQFName(String attrName, SearchParameters.Operator operator, String attrValue, int expected) throws AtlasBaseException {
QuickSearchParameters params = new QuickSearchParameters();
params.setTypeName(HIVE_TABLE_TYPE);
SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition(attrName, operator, attrValue);
params.setEntityFilters(filterCriteria);
params.setLimit(20);
AtlasQuickSearchResult searchResult = discoveryService.quickSearch(params);
assertSearchResult(searchResult.getSearchResults(), expected, attrValue);
if (expected > 0) {
assertAggregationMetrics(searchResult);
}
}
use of org.apache.atlas.model.discovery.AtlasQuickSearchResult in project atlas by apache.
the class AtlasDiscoveryServiceTest method specialCharQuickSearch.
@Test(dataProvider = "specialCharQuickSearch")
public void specialCharQuickSearch(String searchValue, int expected) throws AtlasBaseException {
QuickSearchParameters params = new QuickSearchParameters();
params.setQuery(searchValue);
params.setLimit(5);
params.setOffset(0);
AtlasQuickSearchResult searchResult = discoveryService.quickSearch(params);
assertSearchResult(searchResult.getSearchResults(), expected, searchValue);
if (expected > 0) {
assertAggregationMetrics(searchResult);
}
}
use of org.apache.atlas.model.discovery.AtlasQuickSearchResult in project atlas by apache.
the class AtlasDiscoveryServiceTest method specialCharQuickSearchAssertName.
@Test(dataProvider = "specialCharSearchName")
public void specialCharQuickSearchAssertName(String attrName, SearchParameters.Operator operator, String attrValue, int expected) throws AtlasBaseException {
QuickSearchParameters params = new QuickSearchParameters();
params.setTypeName(HIVE_TABLE_TYPE);
SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition(attrName, operator, attrValue);
params.setEntityFilters(filterCriteria);
params.setLimit(20);
AtlasQuickSearchResult searchResult = discoveryService.quickSearch(params);
assertSearchResult(searchResult.getSearchResults(), expected, attrValue);
if (expected > 0) {
assertAggregationMetrics(searchResult);
}
}
use of org.apache.atlas.model.discovery.AtlasQuickSearchResult in project atlas by apache.
the class EntityDiscoveryService method quickSearch.
@Override
@GraphTransaction
public AtlasQuickSearchResult quickSearch(QuickSearchParameters quickSearchParameters) throws AtlasBaseException {
String query = quickSearchParameters.getQuery();
if (StringUtils.isNotEmpty(query) && !AtlasStructType.AtlasAttribute.hastokenizeChar(query)) {
query = query + "*";
}
quickSearchParameters.setQuery(query);
SearchContext searchContext = new SearchContext(createSearchParameters(quickSearchParameters), typeRegistry, graph, indexer.getVertexIndexKeys());
if (LOG.isDebugEnabled()) {
LOG.debug("Generating the search results for the query {} .", searchContext.getSearchParameters().getQuery());
}
AtlasSearchResult searchResult = searchWithSearchContext(searchContext);
if (LOG.isDebugEnabled()) {
LOG.debug("Generating the aggregated metrics for the query {} .", searchContext.getSearchParameters().getQuery());
}
// load the facet fields and attributes.
Set<String> aggregationFields = getAggregationFields();
Set<AtlasAttribute> aggregationAttributes = getAggregationAtlasAttributes();
SearchAggregator searchAggregator = new SearchAggregatorImpl(searchContext);
Map<String, List<AtlasAggregationEntry>> aggregatedMetrics = searchAggregator.getAggregatedMetrics(aggregationFields, aggregationAttributes);
AtlasQuickSearchResult ret = new AtlasQuickSearchResult(searchResult, aggregatedMetrics);
return ret;
}
Aggregations