I run following simple code which created couple of documents and index. Documents created sucessfully, but index doesn't...
At least, I don see it in RavenDB studio.
namespace RavenDBIndexTesting
{
internal class Program
{
private static void Main(string[] args)
{
documentStore.Initialize();
using (var session = documentStore.OpenSession("TEST"))
{
foreach (var i in new[] {1, 2, 3, 4, 5, 6,})
{
var post = new
{
Name = String.Format("Valentyn Ponomarenko{0}", i),
Text = String.Format("This is sample of the post text.{0}", i)
};
// Saving changes using the session API
session.Store(post);//, @"post\" + Guid.NewGuid());
// Operations against session
}
// Flush those changes
session.SaveChanges();
}
var postIndex = new IndexDefinitionBuilder<Post>()
{
Map = posts => from post in posts
select new {post.Name}
//Index(x => x.Name,
// FieldIndexing.Analyzed);
};
documentStore.DatabaseCommands.PutIndex(@"TEST/PostIndex", postIndex);
//IndexCreation.CreateIndexes(typeof(PostIndex).Assembly, documentStore);
//documentStore.ExecuteIndex(new PostIndex());
}
}
public class Post
{
public string Name { get; set; }
public string Text { get; set; }
}
public class PostIndex : AbstractIndexCreationTask<Post>
{
public override string IndexName
{
get { return "PostIndex1"; }
}
public PostIndex()
{
Map = posts => from post in posts
select new {post.Name};
Index(x => x.Name, FieldIndexing.Analyzed);
}
}
}
}