public async Task <Meilisearch.Index> SetUpIndexForFaceting(string indexUid) { Meilisearch.Index index = await this.DefaultClient.GetOrCreateIndex(indexUid); // Add documents var movies = new[] { new Movie { Id = "10", Name = "Gladiator" }, new Movie { Id = "11", Name = "Interstellar" }, new Movie { Id = "12", Name = "Star Wars", Genre = "SF" }, new Movie { Id = "13", Name = "Harry Potter", Genre = "SF" }, new Movie { Id = "14", Name = "Iron Man", Genre = "Action" }, new Movie { Id = "15", Name = "Spider-Man", Genre = "Action" }, new Movie { Id = "16", Name = "Amélie Poulain", Genre = "French movie" }, new Movie { Id = "17", Name = "Mission Impossible", Genre = "Action" }, }; UpdateStatus update = await index.AddDocuments(movies); // Check the documents have been added UpdateStatus finalUpdateStatus = await index.WaitForPendingUpdate(update.UpdateId); if (finalUpdateStatus.Status != "processed") { throw new Exception("The documents were not added during SetUpIndexForFaceting. Impossible to run the tests."); } // Update settings Settings settings = new Settings { AttributesForFaceting = new string[] { "genre" }, }; update = await index.UpdateSettings(settings); // Check the settings have been added finalUpdateStatus = await index.WaitForPendingUpdate(update.UpdateId); if (finalUpdateStatus.Status != "processed") { throw new Exception("The settings were not added during SetUpIndexForFaceting. Impossible to run the tests."); } return(index); }
public UpdateStatusTests(IndexFixture fixture) { fixture.DeleteAllIndexes().Wait(); // Test context cleaned for each [Fact] var client = fixture.DefaultClient; this.index = fixture.SetUpBasicIndex("BasicIndex-UpdateStatusTests").Result; }
public async Task BasicUsageOfCustomClient() { var httpClient = ClientFactory.Instance.CreateClient <MeilisearchClient>(); MeilisearchClient ms = new MeilisearchClient(httpClient); var indexUid = "uid" + new Random().Next(); Meilisearch.Index index = await ms.CreateIndex(indexUid); var updateStatus = await index.AddDocuments(new[] { new Movie { Id = "1", Name = "Batman" } }); updateStatus.UpdateId.Should().BeGreaterOrEqualTo(0); }
public async void SetUpForFaceting(MeilisearchClient client, string indexUid) { this.IndexForFaceting = client.GetOrCreateIndex(indexUid).Result; var movies = new[] { new Movie { Id = "10", Name = "Gladiator" }, new Movie { Id = "11", Name = "Interstellar" }, new Movie { Id = "12", Name = "Star Wars", Genre = "SF" }, new Movie { Id = "13", Name = "Harry Potter", Genre = "SF" }, new Movie { Id = "14", Name = "Iron Man", Genre = "Action" }, new Movie { Id = "15", Name = "Spider-Man", Genre = "Action" }, new Movie { Id = "16", Name = "Amélie Poulain", Genre = "French movie" }, new Movie { Id = "17", Name = "Mission Impossible", Genre = "Action" }, }; await this.IndexForFaceting.AddDocuments(movies); Settings settings = new Settings { AttributesForFaceting = new string[] { "genre" }, }; await this.IndexForFaceting.UpdateAllSettings(settings); }
public async Task <Meilisearch.Index> SetUpBasicIndexWithIntId(string indexUid) { Meilisearch.Index index = this.DefaultClient.GetOrCreateIndex(indexUid).Result; var movies = new[] { new MovieWithIntId { Id = 10, Name = "Gladiator" }, new MovieWithIntId { Id = 11, Name = "Interstellar" }, new MovieWithIntId { Id = 12, Name = "Star Wars", Genre = "SF" }, new MovieWithIntId { Id = 13, Name = "Harry Potter", Genre = "SF" }, new MovieWithIntId { Id = 14, Name = "Iron Man", Genre = "Action" }, new MovieWithIntId { Id = 15, Name = "Spider-Man", Genre = "Action" }, new MovieWithIntId { Id = 16, Name = "Amélie Poulain", Genre = "French movie" }, }; UpdateStatus update = await index.AddDocuments(movies); // Check the documents have been added UpdateStatus finalUpdateStatus = await index.WaitForPendingUpdate(update.UpdateId); if (finalUpdateStatus.Status != "processed") { throw new Exception("The documents were not added during SetUpBasicIndexWithIntId. Impossible to run the tests."); } return(index); }
public StatusTests(DocumentFixture fixture) { this.index = fixture.BasicIndexWithDocuments; }