Can IndexCreation only create one index?

19 views
Skip to first unread message

Justin A

unread,
Feb 22, 2012, 5:19:11 PM2/22/12
to rav...@googlegroups.com
Hi folks,

currently, if i want the DocumentStore to create indexes, I do the following :-

IndexCreation.CreateIndexes(typeof (Some_Index_Class).Assembly, documentStore);

and this does a scan of the assembly for any indexes. Great :)

Now, is there a way we can specify only ONE index to add? I know there's a PUT indexing thingy .. but I thought that requires the index code. I was just hoping to provide the class name (like above) .. but it doesn't scan. just adds it.

Why? In my tests project, I'm hoping to specify the only index (or indexes) which the tests uses .. to give the test a bit more speed. Why index indexes which won't be used in the test? I know this doesn't have an impact on the output .. just the TIME to output .. but i was just curious none-the-less :)

-me-

Itamar Syn-Hershko

unread,
Feb 22, 2012, 5:20:10 PM2/22/12
to rav...@googlegroups.com
new MyIndex().Execute(store);

Daniel Lidström

unread,
Feb 23, 2012, 3:14:05 AM2/23/12
to rav...@googlegroups.com
Create your own composition container where you specify the indexes you wish to create. For example:

var
indexes = from type in Assembly.GetExecutingAssembly().GetTypes()
                          where
                              type.IsSubclassOf(typeof(AbstractIndexCreationTask))
                          select type;

            var typeCatalog = new TypeCatalog(indexes.ToArray());
            IndexCreation.CreateIndexes(new CompositionContainer(typeCatalog), store);

Good luck!

Mauro Servienti

unread,
Feb 23, 2012, 3:31:39 AM2/23/12
to rav...@googlegroups.com
I did it, it works perfectly and lets you do some interesting things :-)

.m
_____________________
it's all about trust...

From: Daniel Lidström
Sent: 23/02/2012 09:14
To: rav...@googlegroups.com
Subject: [RavenDB] Re: Can IndexCreation only create one index?
Reply all
Reply to author
Forward
0 new messages