Skip to content

Commit

Permalink
Fixes around boosting with multiple binary expressions in brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
base33 committed Feb 9, 2016
1 parent 8da9e49 commit 525524d
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 5 deletions.
Binary file modified Blog/bin/Blog.dll
Binary file not shown.
Binary file modified Blog/bin/Blog.pdb
Binary file not shown.
Binary file modified Blog/bin/Umbraco.Examine.Linq.dll
Binary file not shown.
Binary file modified Blog/bin/Umbraco.Examine.Linq.pdb
Binary file not shown.
Binary file modified Blog/obj/Debug/Blog.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file modified Blog/obj/Debug/Blog.dll
Binary file not shown.
Binary file modified Blog/obj/Debug/Blog.pdb
Binary file not shown.
Binary file added LINQToExamine.1.3.nupkg
Binary file not shown.
Binary file added LINQToExamine.1.4.nupkg
Binary file not shown.
2 changes: 1 addition & 1 deletion LINQToExamine.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>LINQToExamine</id>
<title>Linq To Examine for Umbraco</title>
<version>1.2</version>
<version>1.4</version>
<authors>Craig Noble</authors>
<description>This project allows you to query the Lucene indexes using LINQ based on your own classes.</description>
<language>en-US</language>
Expand Down
Binary file modified Umbraco.Examine.Linq.Sandbox/App_Data/Umbraco.sdf
Binary file not shown.
37 changes: 34 additions & 3 deletions Umbraco.Examine.Linq.Sandbox/Views/BlogOverview.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,48 @@
@{
Layout = "Master.cshtml";

var searcher = new Searcher();

var CurrentPage = (Umbraco.Core.Models.IPublishedContent)base.CurrentPage;

var results = new Umbraco.Examine.Linq.Index<Umbraco.Examine.Linq.Sandbox.Models.Content.BlogPost>(new Umbraco.Examine.Linq.Sandbox.Mapper.ConcreteMapper<Umbraco.Examine.Linq.Sandbox.Models.Content.BlogPost>())
.Where(c => c.CreateDate < DateTime.Now);
var results = new Umbraco.Examine.Linq.Index<Umbraco.Examine.Linq.Sandbox.Models.Content.BlogPost>(searcher, new Umbraco.Examine.Linq.Sandbox.Mapper.ConcreteMapper<Umbraco.Examine.Linq.Sandbox.Models.Content.BlogPost>())
.Where(c => c.Name.Contains("tall").Fuzzy(0.5) || c.Name.Contains("f*").Boost(10));
results = results.Where(c => c.CreateDate > DateTime.Now.AddYears(-2) && c.CreateDate < DateTime.Now);

results = results.ToList().AsQueryable();


}

@functions {
public class Searcher : Umbraco.Examine.Linq.ISearcher
{
public string Query { get; set; }

public IEnumerable<Examine.SearchResult> Search(string query)
{
Query = query;
try
{
return new Umbraco.Examine.Linq.SearchProviders.LuceneSearch("ExternalSearcher").Search(query);
}
catch (Exception)
{
Query = "invalid : " + query;
}

return new List<Examine.SearchResult>();
}
}
}

<div role="content">

<section class="light blogarchive equalizer">
<div class="container">

<div class="row">
<p>@searcher.Query</p>
</div>
<div class="row">
@*foreach (var post in new UmbracoNS.Examine.Linq.Sandbox.Repositories.BlogRepository().GetAllBlogPosts())*@
@foreach (var post in results)
Expand Down
5 changes: 4 additions & 1 deletion Umbraco.Examine.Linq/ExpressionTreeVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ protected override Expression VisitMethodCallExpression(MethodCallExpression exp
bracketsEnabled = false;
VisitExpression(expression.Arguments[0]);
VisitExpression(expression.Object);
//addEndBracket();
if((expression.Arguments[0] is BinaryExpression) && expression.Arguments[0].GetType().FullName != "System.Linq.Expressions.LogicalBinaryExpression")
addEndBracket();
currentPart.AppendFormat("^{0}", expression.Arguments[1]);
bracketsEnabled = false;
break;
Expand All @@ -369,6 +370,8 @@ protected override Expression VisitMethodCallExpression(MethodCallExpression exp
if (expression.Arguments.Any())
VisitExpression(expression.Arguments[0]);
VisitExpression(expression.Object);
if (expression.Arguments[0] is BinaryExpression)
addEndBracket();
fuzzy = 0;
bracketsEnabled = false;
break;
Expand Down

0 comments on commit 525524d

Please sign in to comment.