Ejemplo n.º 1
0
        private void GenerateRandomDocs(Random rng, int numDocs)
        {
            SpatialContext ctx = _spatialStrategy.GetSpatialContext();

            base.addDocumentsAndCommit(Enumerable.Range(1, numDocs)
                                       .Select(a => CreateRandomDoc(a, rng, ctx)).ToList());
        }
Ejemplo n.º 2
0
        public static IEnumerable <Document> CreateSearchDocuments(IList <Deal> deals, SpatialStrategy strategy)
        {
            var docs = new List <Document>(deals.Count());
            var ctx  = strategy.GetSpatialContext();

            foreach (var deal in deals)
            {
                foreach (var location in deal.Locations)
                {
                    var doc = new Document();
                    doc.Add(new Field(TitleFieldName, deal.Title, Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field(SupplierFieldName, deal.Supplier, Field.Store.YES, Field.Index.NOT_ANALYZED));
                    doc.Add(new Field(LocationNameFieldName, location.Name, Field.Store.YES, Field.Index.NOT_ANALYZED));

                    foreach (var f in strategy.CreateIndexableFields(ctx.MakePoint(location.Latitude, location.Longitude)))
                    {
                        doc.Add(f);
                    }

                    docs.Add(doc);
                }
            }

            return(docs);
        }
        //  private String fieldName;

        public void Init(Param param)
        {
            SpatialStrategy strategy = param.strategy;

            this.ctx      = strategy.GetSpatialContext();
            this.strategy = strategy;
        }
        public static IList <Document> CreateDocuments(IEnumerable <City> cities, SpatialStrategy strategy)
        {
            var docs = new List <Document>();
            var ctx  = strategy.GetSpatialContext();

            foreach (var city in cities)
            {
                docs.Add(CreateDocument(city.Name, ctx.MakePoint(city.Latitude, city.Longitude), strategy));
            }

            return(docs);
        }
Ejemplo n.º 5
0
        public static IList <Document> CreateDocuments(SpatialStrategy strategy)
        {
            var docs = new List <Document>();
            var ctx  = strategy.GetSpatialContext();

            docs.Add(CreateDocument("London", ctx.MakePoint(0.11, 51.5), strategy));
            docs.Add(CreateDocument("New York", ctx.MakePoint(-74.005970, 40.714270), strategy));
            docs.Add(CreateDocument("Copenhagen", ctx.MakePoint(12.567600, 55.675678), strategy));
            docs.Add(CreateDocument("Sydney", ctx.MakePoint(151.206955, -33.869629), strategy));
            docs.Add(CreateDocument("Paris", ctx.MakePoint(2.341200, 48.856930), strategy));
            docs.Add(CreateDocument("Berlin", ctx.MakePoint(13.376980, 52.516071), strategy));

            return(docs);
        }