public static IDocumentQuery<TextContent> CreateQuery(this DocumentSession session, Schema schema, TextFolder textFolder) { var documentQuery = session.LuceneQuery<TextContent>(schema.GetIndexName()).WaitForNonStaleResultsAsOfNow(TextContentProvider.WaitTimeout); if (textFolder != null) { documentQuery = documentQuery.WhereEquals("FolderName", textFolder.FullName.ToLower()); } return documentQuery; }
public virtual void CreateIndex(Schema schema) { var documentStore = GetStore(schema.Repository.Name); IDictionary<string, string> analyzers = new Dictionary<string, string>(); analyzers.Add("UUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); analyzers.Add("FolderName", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); analyzers.Add("UserKey", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); analyzers.Add("SchemaName", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); analyzers.Add("ParentUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); analyzers.Add("OriginalUUID", "Kooboo.CMS.Content.Persistence.RavenDB.Indexing.Analyzers.KeywordToLowerAnalyzer,Kooboo.CMS.Content.Persistence.RavenDB.Indexing"); //why to use UUID not Id. http://groups.google.com/group/ravendb/browse_thread/thread/c3bf34c64d726188/8580d8b6060715c4?lnk=gst&q=LuceneQuery+for+id#8580d8b6060715c4 documentStore.DatabaseCommands.PutIndex(schema.GetIndexName(), new IndexDefinition() { Map = string.Format(@"from doc in docs where doc[""@metadata""][""ContentType""] == ""TextContent"" && doc[""@metadata""][""SchemaName""] == ""{0}"" select new {{{1}}}", schema.Name, GetIndexColumn(schema)) //Analyzers = analyzers }, true); }
public virtual void DeleteIndex(Schema schema) { var documentStore = GetStore(schema.Repository.Name); documentStore.DatabaseCommands.DeleteIndex(schema.GetIndexName()); }