Exemple #1
0
        public QueryNoticesResponse QueryNotices(string environmentId, string collectionId, string filter = null, string query = null, string naturalLanguageQuery = null, bool?passages = null, string aggregation = null, long?count = null, List <string> _return = null, long?offset = null, string sort = null, bool?highlight = null)
        {
            if (string.IsNullOrEmpty(environmentId))
            {
                throw new ArgumentNullException(nameof(environmentId));
            }
            if (string.IsNullOrEmpty(collectionId))
            {
                throw new ArgumentNullException(nameof(collectionId));
            }

            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null. Use 'DISCOVERY_VERSION_DATE_2016_12_01'");
            }

            QueryNoticesResponse result = null;

            try
            {
                result = this.Client.WithAuthentication(this.UserName, this.Password)
                         .GetAsync($"{this.Endpoint}/v1/environments/{environmentId}/collections/{collectionId}/notices")
                         .WithArgument("version", VersionDate)
                         .WithArgument("filter", filter)
                         .WithArgument("query", query)
                         .WithArgument("natural_language_query", naturalLanguageQuery)
                         .WithArgument("passages", passages)
                         .WithArgument("aggregation", aggregation)
                         .WithArgument("count", count)
                         .WithArgument("return", _return)
                         .WithArgument("offset", offset)
                         .WithArgument("sort", sort)
                         .WithArgument("highlight", highlight)
                         .As <QueryNoticesResponse>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
Exemple #2
0
        public IEnumerator TestQueryNotices()
        {
            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to QueryNotices...");
            QueryNoticesResponse queryNoticesResponse = null;

            service.QueryNotices(
                callback: (DetailedResponse <QueryNoticesResponse> response, IBMError error) =>
            {
                Log.Debug("DiscoveryServiceV2IntegrationTests", "QueryNotices result: {0}", response.Response);
                queryNoticesResponse = response.Result;
                Assert.IsNotNull(queryNoticesResponse);
                Assert.IsNull(error);
            },
                projectId: projectId,
                query: "relations.action.lemmatized:acquire"
                );

            while (queryNoticesResponse == null)
            {
                yield return(null);
            }
        }