Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

RDoc-63. Minor adjustments to FullTextSearch sample.

  • Loading branch information...
commit bd92d708b2aebd2fe5049c2a6ba010d785318b20 1 parent 2eb3f00
@ppekrol ppekrol authored
Showing with 38 additions and 32 deletions.
  1. +38 −32 Samples/Raven.Sample.FullTextSearch/Program.cs
View
70 Samples/Raven.Sample.FullTextSearch/Program.cs
@@ -1,51 +1,52 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Raven.Abstractions.Indexing;
-using Raven.Client;
-using Raven.Client.Embedded;
-using Raven.Client.Indexes;
-using Raven.Client.Linq;
-
-namespace Raven.Sample.FullTextSearch
+namespace Raven.Sample.FullTextSearch
{
- class Program
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ using Raven.Abstractions.Indexing;
+ using Raven.Client;
+ using Raven.Client.Embedded;
+ using Raven.Client.Indexes;
+ using Raven.Client.Linq;
+
+ public class Program
{
- static void Main(string[] args)
+ private static readonly IList<string> People = new List<string> { "Ayende Rahien", "Oren Eini", "Oscar Eini", "Arava Eini" };
+
+ public static void Main(string[] args)
{
- using(var store = new EmbeddableDocumentStore
+ using (var store = new EmbeddableDocumentStore
{
RunInMemory = true,
UseEmbeddedHttpServer = true
}.Initialize())
{
-
IndexCreation.CreateIndexes(typeof(Program).Assembly, store);
StoreDocs(store);
-
+
while (true)
{
Console.Write("Enter name: ");
var name = Console.ReadLine();
- using(var session = store.OpenSession())
+ using (var session = store.OpenSession())
{
Console.WriteLine("Equality");
- foreach (var person in Queryable.Where(session.Query<Person, People_ByName_FullTextSearch>(), x => x.Name == name))
+ foreach (var person in session.Query<Person, People_ByName_FullTextSearch>().Where(x => x.Name == name))
{
Console.WriteLine(person.Name);
}
Console.WriteLine();
- Console.WriteLine("Simple starts with");
- foreach (var person in Queryable.Where(session.Query<Person, People_ByName_FullTextSearch>(), x => x.Name.StartsWith(name)))
+ Console.WriteLine("Simple starts with:");
+ foreach (var person in session.Query<Person, People_ByName_FullTextSearch>().Where(x => x.Name.StartsWith(name)))
{
Console.WriteLine(person.Name);
}
- Console.WriteLine("Complex starts with");
+ Console.WriteLine("Complex starts with:");
IQueryable<Person> query = session.Query<Person, People_ByName_FullTextSearch>();
@@ -55,29 +56,34 @@ static void Main(string[] args)
{
Console.WriteLine(person.Name);
}
-
}
}
-
-
}
}
private static void StoreDocs(IDocumentStore store)
{
- using(var session = store.OpenSession())
+ using (var session = store.OpenSession())
{
- session.Store(new Person{Name = "Ayende Rahien"});
- session.Store(new Person{Name = "Oren Eini"});
- session.Store(new Person{ Name = "Oscar Eini" });
- session.Store(new Person{ Name = "Arava Eini" });
+ foreach (var person in People)
+ {
+ session.Store(new Person { Name = person });
+ }
session.SaveChanges();
}
+
+ Console.WriteLine("Stored:");
+ foreach (var person in People)
+ {
+ Console.WriteLine("{0}", person);
+ }
+
+ Console.WriteLine();
}
}
- public class Person
+ public class Person
{
public string Name { get; set; }
}
@@ -87,8 +93,8 @@ public class People_ByName_FullTextSearch : AbstractIndexCreationTask<Person>
public People_ByName_FullTextSearch()
{
Map = people => from person in people
- select new {person.Name};
- Index(x=>x.Name, FieldIndexing.Analyzed);
+ select new { person.Name };
+ Index(x => x.Name, FieldIndexing.Analyzed);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.