public async Task Search() { List <DocTest> _docs = new List <DocTest> { new DocTest { Id = "8", Date = new DateTime(2020, 1, 1), Ndouble = 3.4, Nint = 4, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } }, new DocTest { Id = "9a", Date = new DateTime(2021, 1, 1), Ndouble = 2020.1, Nint = 4, SubDocTest = null } }; MeilisearchDotnet.Types.SearchResponse <DocTest> result = await index.Search <DocTest>("2020"); Assert.Equal(JsonSerializer.Serialize(_docs), JsonSerializer.Serialize(result.Hits)); }
public async Task SearchWithParam() { List <DocTest> _docs_limit_1 = new List <DocTest> { new DocTest { Id = "8", Date = new DateTime(2020, 1, 1), Ndouble = 3.4, Nint = 4, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "efgh" } } } }; List <DocTest> _docs_limit_1_bis = new List <DocTest> { new DocTest { Id = "7", Date = DateTime.MinValue, Ndouble = 4.8, Nint = 0, SubDocTest = new SubDocTest[] { new SubDocTest { str = "abcd" }, new SubDocTest { str = "e=e&e %" } } }, }; List <DocTest> _docs_limit_1_offset_1 = new List <DocTest> { new DocTest { Id = "9a", Date = new DateTime(2021, 1, 1), Ndouble = 2020.1, Nint = 4, SubDocTest = null } }; List <DocTest> _docs_AttributesToRetrieve_id = new List <DocTest> { new DocTest { Id = "8", Date = DateTime.MinValue, Ndouble = 0.0, Nint = 0, SubDocTest = null } }; MeilisearchDotnet.Types.SearchRequest options = new MeilisearchDotnet.Types.SearchRequest { Offset = 0, Limit = 1 }; MeilisearchDotnet.Types.SearchResponse <DocTest> result = await index.Search <DocTest>("2020", options); Assert.Equal(JsonSerializer.Serialize(_docs_limit_1), JsonSerializer.Serialize(result.Hits)); Assert.Equal(0, result.Offset); Assert.Equal(1, result.Limit); result = await index.Search <DocTest>("e=e&e %", options); Assert.Equal(JsonSerializer.Serialize(_docs_limit_1_bis), JsonSerializer.Serialize(result.Hits)); options.Offset = 1; result = await index.Search <DocTest>("2020", options); Assert.Equal(JsonSerializer.Serialize(_docs_limit_1_offset_1), JsonSerializer.Serialize(result.Hits)); Assert.Equal(1, result.Offset); Assert.Equal(1, result.Limit); result = await index.Search <DocTest>("e=e&e %", options); Assert.Equal(JsonSerializer.Serialize(new List <DocTest> { }), JsonSerializer.Serialize(result.Hits)); options.Offset = 0; options.AttributesToRetrieve = new string[] { "Id" }; result = await index.Search <DocTest>("2020", options); Assert.Equal(JsonSerializer.Serialize(_docs_AttributesToRetrieve_id), JsonSerializer.Serialize(result.Hits)); Assert.Equal(0, result.Offset); Assert.Equal(1, result.Limit); }