Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I need Recommendations to fetch the Recommendations record but when i used GetRecommendationsAsync as inside that pass request i get error like {"message":"Index does not exist","status":404} i double check everything like index name and api key and permissions as well. So any solution. #139

Open
mohammadaltamas opened this issue May 11, 2023 · 1 comment

Comments

@mohammadaltamas
Copy link

var requests = new List {
new RecommendRequest {
IndexName = l.Items[0].Name, //here is index name
ObjectID = "333434349435",
Model = "related-products",
Threshold = 10,
MaxRecommendations = 10,
QueryParameters = new Query(),
FallbackParameters = new Query()
}
};

        var recommendationClient = new RecommendClient(algApplicationId, algAdminApiKey);

        var res = client.GetApiKey(algAdminApiKey);

        if (res.Acl.Contains("recommendation"))
        {
            Console.WriteLine("ok");
        }

        try
        {
            
            var task = Task.Run(() => recommendationClient.GetRecommendationsAsync<NewsDetail>(requests));
            if (task.Wait(TimeSpan.FromSeconds(300)))
            {
                var response = task;
                Console.WriteLine($"ObjectID: {response}");
            }
            else
            {
                throw new Exception("Request Timed out");
            }
        }
        catch (AggregateException ex)
        {

            foreach (var inner in ex.InnerExceptions)
            {
                Console.WriteLine(inner.Message);
            }

        }
@mohammadaltamas
Copy link
Author

i am done this code in .net core 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant