protected void TestCanSuggestDynamicDocuments() { SearchIndexClient client = GetClientForQuery(); var suggestParameters = new SuggestParameters() { OrderBy = new[] { "hotelId" } }; DocumentSuggestResponse response = client.Documents.Suggest("good", "sg", suggestParameters); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Null(response.Coverage); Assert.NotNull(response.Results); Document[] expectedDocs = Data.TestDocuments .Where(h => h.HotelId == "4" || h.HotelId == "5") .OrderBy(h => h.HotelId) .Select(h => h.AsDocument()) .ToArray(); Assert.Equal(expectedDocs.Length, response.Results.Count); for (int i = 0; i < expectedDocs.Length; i++) { SearchAssert.DocumentsEqual(expectedDocs[i], response.Results[i].Document); Assert.Equal(expectedDocs[i]["description"], response.Results[i].Text); } }
public void GetDynamicDocumentCannotAlwaysDetermineCorrectType() { Run(() => { SearchIndexClient client = Data.GetSearchIndexClient(); var indexedDoc = new Document() { { "hotelId", "1" }, { "baseRate", Double.NaN }, { "hotelName", "2015-02-11T12:58:00Z" } }; var expectedDoc = new Document() { { "hotelId", "1" }, { "baseRate", "NaN" }, { "hotelName", new DateTimeOffset(2015, 2, 11, 12, 58, 0, TimeSpan.Zero) } }; var batch = new IndexBatch(new[] { new IndexAction(indexedDoc) }); client.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentGetResponse getResponse = client.Documents.Get("1", indexedDoc.Keys); Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); SearchAssert.DocumentsEqual(expectedDoc, getResponse.Document); }); }
public void CanGetDynamicDocumentWithNullOrEmptyValues() { Run(() => { SearchIndexClient client = Data.GetSearchIndexClient(); var expectedDoc = new Document() { { "hotelId", "1" }, { "baseRate", null }, { "hotelName", null }, { "tags", new string[0] }, { "parkingIncluded", null }, { "lastRenovationDate", null }, { "rating", null }, { "location", null } }; var batch = new IndexBatch(new[] { new IndexAction(expectedDoc) }); client.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentGetResponse getResponse = client.Documents.Get("1", expectedDoc.Keys); Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); SearchAssert.DocumentsEqual(expectedDoc, getResponse.Document); }); }
public void CanGetDynamicDocument() { Run(() => { SearchIndexClient client = Data.GetSearchIndexClient(); var expectedDoc = new Document() { { "hotelId", "1" }, { "baseRate", 199.0 }, { "description", "Best hotel in town" }, { "descriptionFr", "Meilleur hôtel en ville" }, { "hotelName", "Fancy Stay" }, { "category", "Luxury" }, { "tags", new[] { "pool", "view", "wifi", "concierge" } }, { "parkingIncluded", false }, { "smokingAllowed", false }, { "lastRenovationDate", new DateTimeOffset(2010, 6, 27, 0, 0, 0, TimeSpan.FromHours(-8)) }, { "rating", 5L }, { "location", GeographyPoint.Create(47.678581, -122.131577) } }; var batch = new IndexBatch(new[] { new IndexAction(expectedDoc) }); client.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentGetResponse getResponse = client.Documents.Get("1"); Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); SearchAssert.DocumentsEqual(expectedDoc, getResponse.Document); }); }
protected void TestCanSearchDynamicDocuments() { SearchIndexClient client = GetClientForQuery(); DocumentSearchResponse response = client.Documents.Search("*"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Null(response.ContinuationToken); Assert.Null(response.Count); Assert.Null(response.Coverage); Assert.Null(response.Facets); Assert.NotNull(response.Results); Assert.Equal(Data.TestDocuments.Length, response.Results.Count); for (int i = 0; i < response.Results.Count; i++) { Assert.Equal(1, response.Results[i].Score); Assert.Null(response.Results[i].Highlights); SearchAssert.DocumentsEqual(Data.TestDocuments[i].AsDocument(), response.Results[i].Document); } }
public void CanGetDocumentWithBase64EncodedKey() { Run(() => { SearchIndexClient client = Data.GetSearchIndexClient(); string complexKey = HttpServerUtility.UrlTokenEncode(new byte[] { 1, 2, 3, 4, 5 }); var expectedDoc = new Document() { { "hotelId", complexKey } }; var batch = new IndexBatch(new[] { new IndexAction(expectedDoc) }); client.Documents.Index(batch); SearchTestUtilities.WaitForIndexing(); DocumentGetResponse getResponse = client.Documents.Get(complexKey, expectedDoc.Keys); Assert.Equal(HttpStatusCode.OK, getResponse.StatusCode); SearchAssert.DocumentsEqual(expectedDoc, getResponse.Document); }); }