当前位置: 首页>>代码示例>>C#>>正文


C# Indexing.IndexDefinition类代码示例

本文整理汇总了C#中Raven.Database.Indexing.IndexDefinition的典型用法代码示例。如果您正苦于以下问题:C# IndexDefinition类的具体用法?C# IndexDefinition怎么用?C# IndexDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IndexDefinition类属于Raven.Database.Indexing命名空间,在下文中一共展示了IndexDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateIndexImplementation

		private Index CreateIndexImplementation(string name, IndexDefinition indexDefinition, Lucene.Net.Store.Directory directory)
		{
		    var viewGenerator = indexDefinitionStorage.GetViewGenerator(name);
		    return indexDefinition.IsMapReduce
                ? (Index)new MapReduceIndex(directory, name, indexDefinition, viewGenerator)
                : new SimpleIndex(directory, name, indexDefinition, viewGenerator);
		}
开发者ID:dplaskon,项目名称:ravendb,代码行数:7,代码来源:IndexStorage.cs

示例2: MapReduceIndex

 public MapReduceIndex(Directory directory, int id, IndexDefinition indexDefinition,
                       AbstractViewGenerator viewGenerator, WorkContext context)
     : base(directory, id, indexDefinition, viewGenerator, context)
 {
     jsonSerializer = JsonExtensions.CreateDefaultJsonSerializer();
     jsonSerializer.Converters = MapReduceConverters;
 }
开发者ID:VPashkov,项目名称:ravendb,代码行数:7,代码来源:MapReduceIndex.cs

示例3: DynamicViewCompiler

 public DynamicViewCompiler(string name, IndexDefinition indexDefinition, AbstractDynamicCompilationExtension[] extensions)
 {
     this.indexDefinition = indexDefinition;
     this.extensions = extensions;
     this.name = MonoHttpUtility.UrlEncode(name);
     RequiresSelectNewAnonymousType = true;
 }
开发者ID:vinone,项目名称:ravendb,代码行数:7,代码来源:DynamicViewCompiler.cs

示例4: OpenOrCreateLuceneDirectory

		protected Lucene.Net.Store.Directory OpenOrCreateLuceneDirectory(IndexDefinition indexDefinition, string indexName = null)
		{
			Lucene.Net.Store.Directory directory;
			if (indexDefinition.IsTemp || configuration.RunInMemory)
			{
				directory = new RAMDirectory();
				new IndexWriter(directory, dummyAnalyzer, IndexWriter.MaxFieldLength.UNLIMITED).Close(); // creating index structure
			}
			else
			{
				var indexDirectory = indexName ?? IndexDefinitionStorage.FixupIndexName(indexDefinition.Name, path);
				var indexFullPath = Path.Combine(path, MonoHttpUtility.UrlEncode(indexDirectory));
				directory = FSDirectory.Open(new DirectoryInfo(indexFullPath));

				if (!IndexReader.IndexExists(directory))
				{
					//creating index structure if we need to
					new IndexWriter(directory, dummyAnalyzer, IndexWriter.MaxFieldLength.UNLIMITED).Close();
				}
				else
				{
					// forcefully unlock locked indexes if any
					if (IndexWriter.IsLocked(directory))
						IndexWriter.Unlock(directory);
				}
			}

			return directory;
		}
开发者ID:maurodx,项目名称:ravendb,代码行数:29,代码来源:IndexStorage.cs

示例5: ToLuceneSortField

		public Lucene.Net.Search.SortField ToLuceneSortField(IndexDefinition definition)
		{
			var sortOptions = definition.GetSortOption(Field);
			if(sortOptions == null)
				return new  Lucene.Net.Search.SortField(Field, CultureInfo.InvariantCulture, Descending);
			return new Lucene.Net.Search.SortField(Field, (int)sortOptions.Value);
		}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:7,代码来源:SortedField.cs

示例6: Convert_select_many_will_keep_doc_id

        public void Convert_select_many_will_keep_doc_id()
        {
            IndexDefinition indexDefinition = new IndexDefinition<Order>
            {
                Map = orders => from order in orders
                                from line in order.OrderLines
                                select new { line.ProductId }
            }.ToIndexDefinition(new DocumentConvention());
			var generator = new DynamicViewCompiler("test", indexDefinition, new AbstractDynamicCompilationExtension[0])
                .GenerateInstance();


            var results = generator.MapDefinition(new[]
			{
				GetDocumentFromString(
				@"
                {
                    '@metadata': {'Raven-Entity-Name': 'Orders', '@id': 1},
                    'OrderLines': [{'ProductId': 2}, {'ProductId': 3}]
                }"),
				  GetDocumentFromString(
				@"
                {
                    '@metadata': {'Raven-Entity-Name': 'Orders', '@id': 2},
                    'OrderLines': [{'ProductId': 5}, {'ProductId': 4}]
                }")
			}).Cast<object>().ToArray();

            foreach (var result in results)
            {
                Assert.NotNull(TypeDescriptor.GetProperties(result).Find("__document_id", true));
            }
        }
开发者ID:bstrausser,项目名称:ravendb,代码行数:33,代码来源:LinqIndexesFromClient.cs

示例7: AddIndex

 public string AddIndex(string name, IndexDefinition indexDefinition)
 {
     DynamicViewCompiler transformer = AddAndCompileIndex(name, indexDefinition);
     if(configuration.RunInMemory == false)
         File.WriteAllText(Path.Combine(path, transformer.Name + ".index"), JsonConvert.SerializeObject(indexDefinition, Formatting.Indented, new JsonEnumConverter()));
     return transformer.Name;
 }
开发者ID:vinone,项目名称:ravendb,代码行数:7,代码来源:IndexDefinitionStorage.cs

示例8: RetrieveDocumentInternal

		private JsonDocument RetrieveDocumentInternal(
			IndexQueryResult queryResult,
			HashSet<string> loadedIds,
			IEnumerable<string> fieldsToFetch, 
			IndexDefinition indexDefinition,
			AggregationOperation aggregationOperation)
		{
			if (queryResult.Projection == null)
			{
				// duplicate document, filter it out
				if (loadedIds.Add(queryResult.Key) == false)
					return null;
				return GetDocumentWithCaching(queryResult.Key);
			}

			if (fieldsToFetch != null)
			{
				if (indexDefinition.IsMapReduce == false)
				{
					bool hasStoredFields = false;
					foreach (var fieldToFetch in fieldsToFetch)
					{
						FieldStorage value;
						if (indexDefinition.Stores.TryGetValue(fieldToFetch, out value) == false &&
							value != FieldStorage.No)
							continue;
						hasStoredFields = true;
					}
					if (hasStoredFields == false)
					{
						// duplicate document, filter it out
						if (loadedIds.Add(queryResult.Key) == false)
							return null;
					}
				}
				if (aggregationOperation != AggregationOperation.None)
				{
					var aggOpr = aggregationOperation & ~AggregationOperation.Dynamic;
					fieldsToFetch = fieldsToFetch.Concat(new[] {aggOpr.ToString()});
				}
				var fieldsToFetchFromDocument = fieldsToFetch.Where(fieldToFetch => queryResult.Projection.Property(fieldToFetch) == null);
				var doc = GetDocumentWithCaching(queryResult.Key);
				if (doc != null)
				{
					var result = doc.DataAsJson.SelectTokenWithRavenSyntax(fieldsToFetchFromDocument.ToArray());
					foreach (var property in result.Properties())
					{
						if(property.Value == null || property.Value.Type == JTokenType.Null)
							continue;
						queryResult.Projection[property.Name] = property.Value;
					}
				}
			}

			return new JsonDocument
			{
				Key = queryResult.Key,
				Projection = queryResult.Projection,
			};
		}
开发者ID:aduggleby,项目名称:ravendb,代码行数:60,代码来源:DocumentRetriever.cs

示例9: ReadIndexesFromCatalog

	    private void ReadIndexesFromCatalog(IEnumerable<AbstractViewGenerator> compiledGenerators, ITransactionalStorage transactionalStorage)
	    {
	        foreach (var generator in compiledGenerators)
	        {
	            var copy = generator;
	            var displayNameAtt = TypeDescriptor.GetAttributes(copy)
	                .OfType<DisplayNameAttribute>()
	                .FirstOrDefault();

	            var name = displayNameAtt != null ? displayNameAtt.DisplayName : copy.GetType().Name;

	            transactionalStorage.Batch(actions =>
	            {
	                if (actions.Indexing.GetIndexesStats().Any(x => x.Name == name))
	                    return;

	                actions.Indexing.AddIndex(name);
	            });

	            var indexDefinition = new IndexDefinition
	            {
	                Map = "Compiled map function: " + generator.GetType().AssemblyQualifiedName,
	                // need to supply this so the index storage will create map/reduce index
	                Reduce = generator.ReduceDefinition == null ? null : "Compiled reduce function: " + generator.GetType().AssemblyQualifiedName,
	                Indexes = generator.Indexes,
	                Stores = generator.Stores,
	                IsCompiled = true
	            };
	            indexCache.AddOrUpdate(name, copy, (s, viewGenerator) => copy);
	            indexDefinitions.AddOrUpdate(name, indexDefinition, (s1, definition) => indexDefinition);
	        }
	    }
开发者ID:dplaskon,项目名称:ravendb,代码行数:32,代码来源:IndexDefinitionStorage.cs

示例10: AnonymousObjectToLuceneDocumentConverter

		public AnonymousObjectToLuceneDocumentConverter(DocumentDatabase database, IndexDefinition indexDefinition, AbstractViewGenerator viewGenerator, ILog log)
		{
			this.database = database;
			this.indexDefinition = indexDefinition;
			this.viewGenerator = viewGenerator;
			this.log = log;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:7,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例11: Index

 public static IEnumerable<AbstractField> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition, Field.Store defaultStorage)
 {
     return (from property in properties.Cast<PropertyDescriptor>()
             let name = property.Name
             where name != "__document_id"
             let value = property.GetValue(val)
             where value != null
             select Createfield(name, value, indexDefinition, defaultStorage));
 }
开发者ID:kenegozi,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例12: Index

		public static IEnumerable<AbstractField> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition, Field.Store defaultStorage)
		{
			return (from property in properties.Cast<PropertyDescriptor>()
			        let name = property.Name
					where name != Constants.DocumentIdFieldName
			        let value = property.GetValue(val)
			        from field in CreateFields(name, value, indexDefinition, defaultStorage)
			        select field);
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例13: GetSort

		internal override Lucene.Net.Search.Sort GetSort(Lucene.Net.Search.Filter filter, IndexDefinition indexDefinition)
		{
			if (SortByDistance == false)
				return base.GetSort(filter, indexDefinition);

			var dsort = new Lucene.Net.Spatial.Tier.DistanceFieldComparatorSource((Lucene.Net.Spatial.Tier.DistanceFilter)filter);

			return new Lucene.Net.Search.Sort(new Lucene.Net.Search.SortField("foo", dsort, false));
		}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:9,代码来源:SpatialIndexQuery.cs

示例14: Index

 public IEnumerable<Field> Index(object val, PropertyDescriptorCollection properties, IndexDefinition indexDefinition)
 {
     return (from property in properties.Cast<PropertyDescriptor>()
             let name = property.Name
             where name != "__document_id"
             let value = property.GetValue(val)
             where value != null
             select new Field(name, ToIndexableString(value, indexDefinition.GetIndex(name)), indexDefinition.GetStorage(name), indexDefinition.GetIndex(name)));
 }
开发者ID:torkelo,项目名称:ravendb,代码行数:9,代码来源:AnonymousObjectToLuceneDocumentConverter.cs

示例15: CanPerformSpatialSearch

		public void CanPerformSpatialSearch()
		{
			var indexDefinition = new IndexDefinition
			{
				Map = "from e in docs.Events select new { Tag = \"Event\", _ = SpatialGenerate(e.Latitude, e.Longitude) }",
				Indexes = {
					{ "Tag", FieldIndexing.NotAnalyzed }
				}
			};

			store.DatabaseCommands.PutIndex("eventsByLatLng", indexDefinition);

			var events = SpatialIndexTestHelper.GetEvents();

			for (int i = 0; i < events.Length; i++)
			{
				store.DatabaseCommands.Put("Events/" + (i + 1), null,
					RavenJObject.FromObject(events[i]),
					RavenJObject.Parse("{'Raven-Entity-Name': 'Events'}"));
			}

			const double lat = 38.96939, lng = -77.386398;
			const double radiusInKm = 6.0*1.609344;
			QueryResult queryResult;
			do
			{
				queryResult = store.DatabaseCommands.Query("eventsByLatLng", new SpatialIndexQuery()
				{
					Query = "Tag:[[Event]]",
					QueryShape = SpatialIndexQuery.GetQueryShapeFromLatLon(lat, lng, radiusInKm),
					SpatialRelation = SpatialRelation.Within,
					SpatialFieldName = Constants.DefaultSpatialFieldName,
					SortedFields = new[] { new SortedField("__distance"), }
				}, null);
				if (queryResult.IsStale)
					Thread.Sleep(100);
			} while (queryResult.IsStale);

			var expected = events.Count(e => GetGeographicalDistance(lat, lng, e.Latitude, e.Longitude) <= radiusInKm);

			Assert.Equal(expected, queryResult.Results.Count);
			Assert.Equal(7, queryResult.Results.Count);

			double previous = 0;
			foreach (var r in queryResult.Results)
			{
				Event e = r.JsonDeserialization<Event>();

				double distance = GetGeographicalDistance(lat, lng, e.Latitude, e.Longitude);
				Console.WriteLine("Venue: " + e.Venue + ", Distance " + distance);

				Assert.True(distance < radiusInKm);
				Assert.True(distance >= previous);
				previous = distance;
			}
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:56,代码来源:SpatialIndexTest.cs


注:本文中的Raven.Database.Indexing.IndexDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。