ProjectionException throws when executing an EPiServer Find query

Vote:
 

I do have following model in my project

public class DocModel
{
	[Id]
	public int Id { get; set; }
	public string DocName { get; set; }
	public double Rating { get; set; }
}

And, in the Find index, there is a object corresponding to above model

{
	"Id$$number": 719,
	"DocName$$string": "My Doc",
	"Rating$$number": 0
}

But, when I try to execute following query

var docs = SearchClient.Instance.Search()
	.Filter(x => x.Id.Match(719))
	.Select(x => new { DocRating = x.Rating}).GetResult();

It will end-up with an exception

EPiServer.Find.ProjectionException was unhandled
  HResult=-2146232832
  Message=An exception of type ArgumentException was thrown while projecting field Rating$$number.
  Source=EPiServer.Find
  StackTrace:
       at EPiServer.Find.ProjectionHelper.ReplaceExpressionWithConstantFromField(Dictionary`2 args, Expression expression)
       at EPiServer.Find.ProjectionHelper.<>c__DisplayClass35.b__34(Expression expression)
       at EPiServer.Find.Helpers.Linq.ExpressionReplacer`1.Visit(Expression expression)
       at EPiServer.Find.Helpers.Linq.ExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
       at EPiServer.Find.Helpers.Linq.ExpressionVisitor.VisitNew(NewExpression nex)
       at EPiServer.Find.Helpers.Linq.ExpressionVisitor.Visit(Expression exp)
       at EPiServer.Find.Helpers.Linq.ExpressionReplacer`1.Visit(Expression expression)
       at EPiServer.Find.Helpers.Linq.ExpressionReplacer`1.Replace(Expression expression, Func`2 predicate, Func`2 replaceWith)
       at EPiServer.Find.Helpers.Linq.ExpressionExtensions.Replace[TExpression](Expression expression, Func`2 predicate, Func`2 replaceWith)
       at EPiServer.Find.ProjectionHelper.ReplaceMemberAssignmentsWithFieldValues(Expression selector, Dictionary`2 args)
       at EPiServer.Find.ProjectionHelper.GetMappedSearchResultItem[TResult](SearchRequestBody requestBody, SearchHit`1 searchHit)
       at EPiServer.Find.ProjectionHelper.GetMappedResult[TResult](SearchRequestBody requestBody, SearchResults`1 jsonResult)
       at EPiServer.Find.SearchExtensions.GetProjectedResult[TResult](ISearch`1 search, SearchContext context)
       at EPiServer.Find.SearchExtensions.GetResult[TResult](ISearch`1 search)
       at FindTestApp.Program.Main(String[] args) in e:\FindTestApp\FindTestApp\FindTestApp\Program.cs:line 43
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ArgumentException
       HResult=-2147024809
       Message=Argument types do not match
       Source=System.Core
       StackTrace:
            at System.Linq.Expressions.Expression.Constant(Object value, Type type)
            at EPiServer.Find.ProjectionHelper.ReplaceExpressionWithConstantFromField(Dictionary`2 args, Expression expression)
       InnerException: 

So, what is wrong with my query and how do I fix it ?

#133278
Aug 31, 2015 23:04
Vote:
 

I have found out that this ProjectionException is happening when an integer value is in the "Rating" filed. I'm not sure how it happened. But in our system, there are considerable amount of records subject to this exception. So, how can I get rid of this ? any help would be appreciated

#133387
Sep 03, 2015 11:23
Vote:
 

Any Help ?

#136755
Sep 17, 2015 21:51
Vote:
 

Did you ever find the solution for this issue?

#175710
Feb 28, 2017 0:01
Vote:
 

Currently experiencing this using the latest Find version when trying to project an IEnumerable<string> with a single item (multiple items works fine):
http://world.episerver.com/forum/developer-forum/EPiServer-Search/Thread-Container/2017/3/changes-in-deserialization-argumentexception-thrown-when-mapping-lists-with-only-one-value/

#176251
Edited, Mar 14, 2017 14:29
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.