use of org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult in project atlas by apache.
the class QuickStartV2 method search.
private void search() throws Exception {
System.out.println("\nSample DSL Queries: ");
for (String dslQuery : getDSLQueries()) {
try {
AtlasSearchResult results = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
if (results != null) {
List<AtlasEntityHeader> entitiesResult = results.getEntities();
List<AtlasFullTextResult> fullTextResults = results.getFullTextResult();
AttributeSearchResult attribResult = results.getAttributes();
if (CollectionUtils.isNotEmpty(entitiesResult)) {
System.out.println("query [" + dslQuery + "] returned [" + entitiesResult.size() + "] rows.");
} else if (CollectionUtils.isNotEmpty(fullTextResults)) {
System.out.println("query [" + dslQuery + "] returned [" + fullTextResults.size() + "] rows.");
} else if (attribResult != null) {
System.out.println("query [" + dslQuery + "] returned [" + attribResult.getValues().size() + "] rows.");
}
} else {
System.out.println("query [" + dslQuery + "] failed, results:" + results);
}
} catch (Exception e) {
System.out.println("query [" + dslQuery + "] execution failed!");
}
}
}
use of org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult in project atlas by apache.
the class EntityDiscoveryJerseyResourceIT method testSearchUsingFullText.
@Test(enabled = false, dependsOnMethods = "testSearchDSLLimits")
public void testSearchUsingFullText() throws Exception {
AtlasSearchResult searchResult = atlasClientV2.fullTextSearchWithParams(dbName, 10, 0);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), dbName);
assertEquals(searchResult.getQueryType(), AtlasQueryType.FULL_TEXT);
List<AtlasFullTextResult> fullTextResults = searchResult.getFullTextResult();
assertEquals(fullTextResults.size(), 1);
AtlasFullTextResult result = fullTextResults.get(0);
assertNotNull(result.getEntity());
assertEquals(result.getEntity().getTypeName(), DATABASE_TYPE_BUILTIN);
assertNotNull(result.getScore());
// API works without limit and offset
String query = dbName;
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", query);
searchResult = atlasClientV2.fullTextSearch(query);
assertNotNull(searchResult);
assertEquals(searchResult.getFullTextResult().size(), 1);
// verify passed in limits and offsets are used
// higher limit and 0 offset returns all results
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
// offset is used
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 1);
assertEquals(searchResult.getFullTextResult().size(), 1);
// limit is used
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
// higher offset returns 0 results
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 2);
assertEquals(searchResult.getFullTextResult().size(), 1);
}
use of org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult in project incubator-atlas by apache.
the class QuickStartV2 method search.
private void search() throws Exception {
System.out.println("\nSample DSL Queries: ");
for (String dslQuery : getDSLQueries()) {
AtlasSearchResult results = atlasClientV2.dslSearchWithParams(dslQuery, 10, 0);
if (results != null) {
List<AtlasEntityHeader> entitiesResult = results.getEntities();
List<AtlasFullTextResult> fullTextResults = results.getFullTextResult();
AttributeSearchResult attribResult = results.getAttributes();
if (CollectionUtils.isNotEmpty(entitiesResult)) {
System.out.println("query [" + dslQuery + "] returned [" + entitiesResult.size() + "] rows.");
} else if (CollectionUtils.isNotEmpty(fullTextResults)) {
System.out.println("query [" + dslQuery + "] returned [" + fullTextResults.size() + "] rows.");
} else if (attribResult != null) {
System.out.println("query [" + dslQuery + "] returned [" + attribResult.getValues().size() + "] rows.");
}
} else {
System.out.println("query [" + dslQuery + "] failed, results:" + results);
}
}
}
use of org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult in project atlas by apache.
the class EntityDiscoveryService method getIndexQueryResults.
private List<AtlasFullTextResult> getIndexQueryResults(AtlasIndexQuery query, QueryParams params, boolean excludeDeletedEntities) throws AtlasBaseException {
List<AtlasFullTextResult> ret = new ArrayList<>();
Iterator<Result> iter = query.vertices();
while (iter.hasNext() && ret.size() < params.limit()) {
Result idxQueryResult = iter.next();
AtlasVertex vertex = idxQueryResult.getVertex();
if (skipDeletedEntities(excludeDeletedEntities, vertex)) {
continue;
}
String guid = vertex != null ? vertex.getProperty(Constants.GUID_PROPERTY_KEY, String.class) : null;
if (guid != null) {
AtlasEntityHeader entity = entityRetriever.toAtlasEntityHeader(vertex);
Double score = idxQueryResult.getScore();
ret.add(new AtlasFullTextResult(entity, score));
}
}
return ret;
}
use of org.apache.atlas.model.discovery.AtlasSearchResult.AtlasFullTextResult in project incubator-atlas by apache.
the class EntityDiscoveryJerseyResourceIT method testSearchUsingFullText.
@Test(dependsOnMethods = "testSearchDSLLimits")
public void testSearchUsingFullText() throws Exception {
AtlasSearchResult searchResult = atlasClientV2.fullTextSearchWithParams(dbName, 10, 0);
assertNotNull(searchResult);
assertEquals(searchResult.getQueryText(), dbName);
assertEquals(searchResult.getQueryType(), AtlasQueryType.FULL_TEXT);
List<AtlasFullTextResult> fullTextResults = searchResult.getFullTextResult();
assertEquals(fullTextResults.size(), 1);
AtlasFullTextResult result = fullTextResults.get(0);
assertNotNull(result.getEntity());
assertEquals(result.getEntity().getTypeName(), DATABASE_TYPE_BUILTIN);
assertNotNull(result.getScore());
// API works without limit and offset
String query = dbName;
MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
queryParams.add("query", query);
searchResult = atlasClientV2.fullTextSearch(query);
assertNotNull(searchResult);
assertEquals(searchResult.getFullTextResult().size(), 1);
// verify passed in limits and offsets are used
// higher limit and 0 offset returns all results
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
// offset is used
searchResult = atlasClientV2.fullTextSearchWithParams(query, 10, 1);
assertEquals(searchResult.getFullTextResult().size(), 1);
// limit is used
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 0);
assertEquals(searchResult.getFullTextResult().size(), 1);
// higher offset returns 0 results
searchResult = atlasClientV2.fullTextSearchWithParams(query, 1, 2);
assertEquals(searchResult.getFullTextResult().size(), 1);
}
Aggregations