Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Addings tests for all of the above

  • Loading branch information...
commit 8eda777d27be08d530c0a0ae8632a0c0674e8040 1 parent 3dfad7f
@ayende ayende authored
Showing with 71 additions and 1 deletion.
  1. +71 −1 Raven.Tests/Bugs/FullTextSearchOnTags.cs
View
72 Raven.Tests/Bugs/FullTextSearchOnTags.cs
@@ -10,7 +10,8 @@ public class FullTextSearchOnTags : RavenTest
{
public class Image
{
- public string Id { get; set; }
+ public string Id { get; set; }
+ public ICollection<string> Users { get; set; }
public ICollection<string> Tags { get; set; }
}
@@ -42,6 +43,75 @@ public void CanSearchUsingPhrase()
Assert.NotEmpty(images);
}
}
+ }
+
+
+ [Fact]
+ public void MultipleSearches()
+ {
+ using (var store = NewDocumentStore())
+ {
+ using (var session = store.OpenSession())
+ {
+ session.Store(new Image
+ {
+ Tags = new[] { "cats", "animal", "feline" },
+ Users = new[]{"oren", "ayende"}
+ });
+ session.SaveChanges();
+ }
+
+ store.DatabaseCommands.PutIndex("test", new IndexDefinition
+ {
+ Map = "from doc in docs.Images select new { doc.Tags, doc.Users }",
+ });
+
+ using (var session = store.OpenSession())
+ {
+ var query = session.Query<Image>("test")
+ .Customize(x => x.WaitForNonStaleResults())
+ .Search(x => x.Tags, "i love cats")
+ .Search(x=>x.Users, "oren")
+ .ToString();
+ Assert.Equal("Tags:<<i love cats>> Users:<<oren>>", query.Trim());
+ }
+ }
+ }
+
+ [Fact]
+ public void UsingSuggest()
+ {
+ using (var store = NewDocumentStore())
+ {
+ using (var session = store.OpenSession())
+ {
+ session.Store(new Image
+ {
+ Tags = new[] { "cats", "animal", "feline" },
+ Users = new[] { "oren", "ayende" }
+ });
+ session.SaveChanges();
+ }
+
+ store.DatabaseCommands.PutIndex("test", new IndexDefinition
+ {
+ Map = "from doc in docs.Images select new { doc.Tags, doc.Users }",
+ Indexes = {{"Tags", FieldIndexing.Analyzed}}
+ });
+
+ using (var session = store.OpenSession())
+ {
+ session.Query<Image>("test")
+ .Customize(x => x.WaitForNonStaleResults())
+ .ToList();
+
+ var query = session.Query<Image>("test")
+ .Search(x => x.Tags, "anmal lover")
+ .Suggest();
+ Assert.NotEmpty(query.Suggestions);
+ Assert.Equal("animal", query.Suggestions[0]);
+ }
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.