Java Code Examples for org.apache.atlas.model.discovery.AtlasSearchResult#getFullTextResult()

The following examples show how to use org.apache.atlas.model.discovery.AtlasSearchResult#getFullTextResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickStartV2.java    From incubator-atlas with Apache License 2.0 6 votes vote down vote up
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);
        }
    }
}
 
Example 2
Source File: QuickStartV2.java    From atlas with Apache License 2.0 5 votes vote down vote up
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 + "] returned [ 0 ] rows.");
                }
            } else {
                System.out.println("query [" + dslQuery + "] failed, results:" + results);
            }
        } catch (Exception e) {
            System.out.println("query [" + dslQuery + "] execution failed!");
        }
    }
}
 
Example 3
Source File: EntityDiscoveryJerseyResourceIT.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
@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);
}