public void CanGetFullUrlWithSlashOnTheEnd() { using (var store = NewDocumentStore()) using (var server = new HttpServer(store.Configuration, store.DocumentDatabase)) { server.Start(); var documentStore = new DocumentStore { Url = "http://localhost:8080/" }.Initialize(); var session = documentStore.OpenSession(); var entity = new LinqIndexesFromClient.User(); session.Store(entity); Assert.Equal("http://localhost:8080/docs/users/1", session.Advanced.GetDocumentUrl(entity)); } }
private void StartTheServer() { try { var ravenConfiguration = new RavenConfiguration { AnonymousUserAccessMode = AnonymousUserAccessMode.All, Port = _endPoint.Port, ListenerProtocol = ListenerProtocol.Tcp, DataDirectory = _ravenDrivePath }; _documentDatabase = new DocumentDatabase(ravenConfiguration); _documentDatabase.SpinBackgroundWorkers(); _ravenHttpServer = new HttpServer(ravenConfiguration, _documentDatabase); _ravenHttpServer.Start(); } catch (Exception ex) { Log.Error(ex.ToString()); } }
public void CanProjectFromIndex() { using (var documentStore = NewDocumentStore()) using (var httpServer = new HttpServer(documentStore.Configuration, documentStore.DocumentDatabase)) { httpServer.Start(); documentStore.DatabaseCommands.PutIndex("ImagesByTag", new IndexDefinition<Image, ImageByTagSearchModel> { Map = images => from image in images from tag in image.Tags select new { TagName = tag, Images = new[] { image.Id } }, Reduce = results => from result in results group result by result.TagName into g select new { TagName = g.Key, Images = g.SelectMany(x => x.Images).Distinct() }, Stores = { {x => x.TagName, FieldStorage.Yes}, {x => x.Images, FieldStorage.Yes} } , Indexes = { {x => x.TagName, FieldIndexing.NotAnalyzed}, {x => x.Images, FieldIndexing.No} } },true); using(var s = documentStore.OpenSession()) { s.Store(new Image { Id = "images/123", Tags = new[] { "sport", "footbool" } }); s.Store(new Image { Id = "images/234", Tags = new[] { "footbool", "live" } }); s.SaveChanges(); } using (var s = documentStore.OpenSession()) { var imageByTagSearchModels = s.Advanced.LuceneQuery<ImageByTagSearchModel>("ImagesByTag") .OrderBy("TagName") .WaitForNonStaleResults() .ToList(); Assert.Equal("footbool", imageByTagSearchModels[0].TagName); Assert.Equal(2, imageByTagSearchModels[0].Images.Length); Assert.Equal("live", imageByTagSearchModels[1].TagName); Assert.Equal(1, imageByTagSearchModels[1].Images.Length); Assert.Equal("sport", imageByTagSearchModels[2].TagName); Assert.Equal(1, imageByTagSearchModels[2].Images.Length); } } }