Search in sources :

Example 1 with QueryNoticesResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceTest method queryNoticesIsSuccessful.

@Test
public void queryNoticesIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(queryNoticesResp));
    QueryNoticesOptions.Builder builder = new QueryNoticesOptions.Builder(environmentId, collectionId);
    QueryNoticesResponse response = discoveryService.queryNotices(builder.build()).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(Q5_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) QueryNoticesResponse(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse) QueryNoticesOptions(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions) FederatedQueryNoticesOptions(com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 2 with QueryNoticesResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceTest method federatedQueryNoticesIsSuccessful.

@Test
public void federatedQueryNoticesIsSuccessful() throws InterruptedException {
    server.enqueue(jsonResponse(queryNoticesResp));
    FederatedQueryNoticesOptions.Builder builder = new FederatedQueryNoticesOptions.Builder(environmentId, new ArrayList<>(Arrays.asList(collectionId)));
    QueryNoticesResponse response = discoveryService.federatedQueryNotices(builder.build()).execute();
    RecordedRequest request = server.takeRequest();
    assertEquals(Q4_PATH, request.getPath());
    assertEquals(GET, request.getMethod());
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) QueryNoticesResponse(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse) FederatedQueryNoticesOptions(com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions) WatsonServiceUnitTest(com.ibm.watson.developer_cloud.WatsonServiceUnitTest) Test(org.junit.Test)

Example 3 with QueryNoticesResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse in project java-sdk by watson-developer-cloud.

the class DiscoveryServiceIT method queryNoticesCountIsSuccessful.

// queryNotices tests
@Test
public void queryNoticesCountIsSuccessful() {
    String collectionId = setupTestDocuments();
    QueryNoticesOptions.Builder queryBuilder = new QueryNoticesOptions.Builder(environmentId, collectionId);
    queryBuilder.count(5L);
    QueryNoticesResponse queryResponse = discovery.queryNotices(queryBuilder.build()).execute();
    assertTrue(queryResponse.getResults().size() <= 5);
}
Also used : QueryNoticesResponse(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse) QueryNoticesOptions(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions) Test(org.junit.Test) WatsonServiceTest(com.ibm.watson.developer_cloud.WatsonServiceTest)

Example 4 with QueryNoticesResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse in project java-sdk by watson-developer-cloud.

the class Discovery method federatedQueryNotices.

/**
 * Query multiple collection system notices.
 *
 * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when
 * ingesting documents and performing relevance training. See the [Discovery service
 * documentation](https://console.bluemix.net/docs/services/discovery/using.html) for more details on the query
 * language.
 *
 * @param federatedQueryNoticesOptions the {@link FederatedQueryNoticesOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse}
 */
public ServiceCall<QueryNoticesResponse> federatedQueryNotices(FederatedQueryNoticesOptions federatedQueryNoticesOptions) {
    Validator.notNull(federatedQueryNoticesOptions, "federatedQueryNoticesOptions cannot be null");
    String[] pathSegments = { "v1/environments", "notices" };
    String[] pathParameters = { federatedQueryNoticesOptions.environmentId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    builder.query("collection_ids", RequestUtils.join(federatedQueryNoticesOptions.collectionIds(), ","));
    if (federatedQueryNoticesOptions.filter() != null) {
        builder.query("filter", federatedQueryNoticesOptions.filter());
    }
    if (federatedQueryNoticesOptions.query() != null) {
        builder.query("query", federatedQueryNoticesOptions.query());
    }
    if (federatedQueryNoticesOptions.naturalLanguageQuery() != null) {
        builder.query("natural_language_query", federatedQueryNoticesOptions.naturalLanguageQuery());
    }
    if (federatedQueryNoticesOptions.aggregation() != null) {
        builder.query("aggregation", federatedQueryNoticesOptions.aggregation());
    }
    if (federatedQueryNoticesOptions.count() != null) {
        builder.query("count", String.valueOf(federatedQueryNoticesOptions.count()));
    }
    if (federatedQueryNoticesOptions.returnFields() != null) {
        builder.query("return_fields", RequestUtils.join(federatedQueryNoticesOptions.returnFields(), ","));
    }
    if (federatedQueryNoticesOptions.offset() != null) {
        builder.query("offset", String.valueOf(federatedQueryNoticesOptions.offset()));
    }
    if (federatedQueryNoticesOptions.sort() != null) {
        builder.query("sort", RequestUtils.join(federatedQueryNoticesOptions.sort(), ","));
    }
    if (federatedQueryNoticesOptions.highlight() != null) {
        builder.query("highlight", String.valueOf(federatedQueryNoticesOptions.highlight()));
    }
    if (federatedQueryNoticesOptions.deduplicateField() != null) {
        builder.query("deduplicate.field", federatedQueryNoticesOptions.deduplicateField());
    }
    if (federatedQueryNoticesOptions.similar() != null) {
        builder.query("similar", String.valueOf(federatedQueryNoticesOptions.similar()));
    }
    if (federatedQueryNoticesOptions.similarDocumentIds() != null) {
        builder.query("similar.document_ids", RequestUtils.join(federatedQueryNoticesOptions.similarDocumentIds(), ","));
    }
    if (federatedQueryNoticesOptions.similarFields() != null) {
        builder.query("similar.fields", RequestUtils.join(federatedQueryNoticesOptions.similarFields(), ","));
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryNoticesResponse.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) QueryNoticesResponse(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse)

Example 5 with QueryNoticesResponse

use of com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse in project java-sdk by watson-developer-cloud.

the class Discovery method queryNotices.

/**
 * Query system notices.
 *
 * Queries for notices (errors or warnings) that might have been generated by the system. Notices are generated when
 * ingesting documents and performing relevance training. See the [Discovery service
 * documentation](https://console.bluemix.net/docs/services/discovery/using.html) for more details on the query
 * language.
 *
 * @param queryNoticesOptions the {@link QueryNoticesOptions} containing the options for the call
 * @return a {@link ServiceCall} with a response type of {@link QueryNoticesResponse}
 */
public ServiceCall<QueryNoticesResponse> queryNotices(QueryNoticesOptions queryNoticesOptions) {
    Validator.notNull(queryNoticesOptions, "queryNoticesOptions cannot be null");
    String[] pathSegments = { "v1/environments", "collections", "notices" };
    String[] pathParameters = { queryNoticesOptions.environmentId(), queryNoticesOptions.collectionId() };
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, pathParameters));
    builder.query(VERSION, versionDate);
    if (queryNoticesOptions.filter() != null) {
        builder.query("filter", queryNoticesOptions.filter());
    }
    if (queryNoticesOptions.query() != null) {
        builder.query("query", queryNoticesOptions.query());
    }
    if (queryNoticesOptions.naturalLanguageQuery() != null) {
        builder.query("natural_language_query", queryNoticesOptions.naturalLanguageQuery());
    }
    if (queryNoticesOptions.passages() != null) {
        builder.query("passages", String.valueOf(queryNoticesOptions.passages()));
    }
    if (queryNoticesOptions.aggregation() != null) {
        builder.query("aggregation", queryNoticesOptions.aggregation());
    }
    if (queryNoticesOptions.count() != null) {
        builder.query("count", String.valueOf(queryNoticesOptions.count()));
    }
    if (queryNoticesOptions.returnFields() != null) {
        builder.query("return_fields", RequestUtils.join(queryNoticesOptions.returnFields(), ","));
    }
    if (queryNoticesOptions.offset() != null) {
        builder.query("offset", String.valueOf(queryNoticesOptions.offset()));
    }
    if (queryNoticesOptions.sort() != null) {
        builder.query("sort", RequestUtils.join(queryNoticesOptions.sort(), ","));
    }
    if (queryNoticesOptions.highlight() != null) {
        builder.query("highlight", String.valueOf(queryNoticesOptions.highlight()));
    }
    if (queryNoticesOptions.passagesFields() != null) {
        builder.query("passages.fields", RequestUtils.join(queryNoticesOptions.passagesFields(), ","));
    }
    if (queryNoticesOptions.passagesCount() != null) {
        builder.query("passages.count", String.valueOf(queryNoticesOptions.passagesCount()));
    }
    if (queryNoticesOptions.passagesCharacters() != null) {
        builder.query("passages.characters", String.valueOf(queryNoticesOptions.passagesCharacters()));
    }
    if (queryNoticesOptions.deduplicateField() != null) {
        builder.query("deduplicate.field", queryNoticesOptions.deduplicateField());
    }
    if (queryNoticesOptions.similar() != null) {
        builder.query("similar", String.valueOf(queryNoticesOptions.similar()));
    }
    if (queryNoticesOptions.similarDocumentIds() != null) {
        builder.query("similar.document_ids", RequestUtils.join(queryNoticesOptions.similarDocumentIds(), ","));
    }
    if (queryNoticesOptions.similarFields() != null) {
        builder.query("similar.fields", RequestUtils.join(queryNoticesOptions.similarFields(), ","));
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryNoticesResponse.class));
}
Also used : RequestBuilder(com.ibm.watson.developer_cloud.http.RequestBuilder) QueryNoticesResponse(com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse)

Aggregations

QueryNoticesResponse (com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse)5 Test (org.junit.Test)3 WatsonServiceUnitTest (com.ibm.watson.developer_cloud.WatsonServiceUnitTest)2 FederatedQueryNoticesOptions (com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions)2 QueryNoticesOptions (com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions)2 RequestBuilder (com.ibm.watson.developer_cloud.http.RequestBuilder)2 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)2 WatsonServiceTest (com.ibm.watson.developer_cloud.WatsonServiceTest)1