I have one column in database as NAME and it has values with spaces. Ex. let's say, "The quick brown fox jumps over the lazy dog".
CASE1:
So what i want to perform is, as a user when i type "dog" or "lazy" or "fox"(any single word from above statement in a search box it should return me "The quick brown fox jumps over the lazy dog"). This is the CONTAINS scenario.
CASE2:
Another case is STARTS-WITH, as a user when i type "The quick "(ALSO NOTE THE SPACE AT THE END) or "The quick brown"(NO SPACE HERE ) or "The quick brown fox" or "The quick brown fox jumps ", search should return me whole text "The quick brown fox jumps over the lazy dog" from the db.
this.Indexes.Add(x => x.Name, FieldIndexing.Analyzed)
Linq query:
var resultSet = from temp in Query<Model>(Index.NAME) .Where(x => x.Name.StartsWith(RavenQuery.Escape(Searchterm))) select new { temp.Name }
NOTE: Above code is working for CASE1 but not for CASE2. When i change fieldindexing toFieldIndexing.Default
in above index
defination and when i remove
RavenQuery.Escape() from above linq query, CASE2 starts working but CASE1 not works.
So Somehow i need to get both case working.
I spent lot of time going through various posts/articles but unable to figure out the solution. I already tried below approaches:
.Search() tried all search options but nothing helped :(
.In() (When i tried this, query generated was something like @<Name>:"The quick", i was getting @<Name> field is not indexed error.)
Wildcard search
, used Searchterm=string.format("*{0}*",
Searchterm
)
also tried
Searchterm
=Searchterm.replace(" ",@"\ ") as a separately and in .Search method as a search term.
tried using almost all analyzers from raven studio & code.
var resultSet = from temp in Query<Index.Result>(Index.NAME)
.Where(x => x.NotAnalyzedName.StartsWith(Searchterm))
select new { temp.Name }
Hibernating Rhinos Ltd
Grisha Kotler l RavenDB Core Team Developer l Mobile: +972-54-586-8647
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
RavenDB paving the way to "Data Made Simple" http://ravendb.net/
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.