private static void SetupFacets( String id, IDocumentStore store )
        {
            var facet = new FacetSetup()
            {
                Id = id,
                Facets =
                {
                    new Facet<Orders.Product>()
                    {
                        Name = p=>p.Supplier
                    },
                    new Facet<Orders.Product>()
                    {
                        Name = p=>p.PricePerUser,
                        Ranges =
                        {
                            p=>p.PricePerUser <= 50,
                            p=>p.PricePerUser > 50 && p.PricePerUser <= 100,
                            p=>p.PricePerUser > 100 && p.PricePerUser <= 200,
                            p=>p.PricePerUser > 200,
                        }
                    },
                }
            };

            using ( var session = store.OpenSession() )
            {
                session.Store( facet );
                session.SaveChanges();
            }
        }
Beispiel #2
0
		private void Setup(IDocumentStore store, List<Facet> facetsToUse)
		{
			using (var s = store.OpenSession())
			{
				var facetSetupDoc = new FacetSetup { Id = "facets/CameraFacets", Facets = facetsToUse };
				s.Store(facetSetupDoc);
				s.SaveChanges();

				store.DatabaseCommands.PutIndex("CameraCost",
												new IndexDefinition
												{
													Map =
														@"from camera in docs 
                                                        select new 
                                                        { 
                                                            camera.Manufacturer, 
                                                            camera.Model, 
                                                            camera.Cost,
                                                            camera.DateOfListing,
                                                            camera.Megapixels
                                                        }"
												});

				foreach (var camera in _data)
				{
					s.Store(camera);
				}
				s.SaveChanges();

				s.Query<Camera>("CameraCost")
					.Customize(x => x.WaitForNonStaleResults())
					.ToList();
			}
		}
Beispiel #3
0
        private void Setup(IDocumentStore store, List<Facet> facetsToUse)
        {
            using (var s = store.OpenSession())
            {
                var facetSetupDoc = new FacetSetup {Id = "facets/CameraFacets", Facets = facetsToUse};
                s.Store(facetSetupDoc);
                s.SaveChanges();
            }

            CreateCameraCostIndex(store);

            InsertCameraDataAndWaitForNonStaleResults(store, _data);
        }