Fix: There is no method ‘Filter’ on type ‘Sitecore.ContentSearch.Linq.QueryableExtensions’ that matches the specified arguments

Recently while working for the project, I ran into a waired issue. Our Sitecore app is hosted on Azure as a PaaS. Most of the time after deployment to CM instance, I find the following exception in the log files.

2018-07-26T09:56:20,Error,staging-cm,5e677a,636681957806235659,0,5920,7,"6136 09:56:20 ERROR Foundation.TagAndFilter, FilterSearchRepository:GetFilterTagItems
Exception: System.InvalidOperationException
Message: There is no method 'Filter' on type 'Sitecore.ContentSearch.Linq.QueryableExtensions' that matches the specified arguments
Source: System.Core
   at System.Linq.EnumerableRewriter.FindMethod(Type type, String name, ReadOnlyCollection`1 args, Type[] typeArgs, BindingFlags flags)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.Expressions.OldExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.Expressions.OldExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.Expressions.OldExpressionVisitor.VisitExpressionList(ReadOnlyCollection`1 original)
   at System.Linq.EnumerableRewriter.VisitMethodCall(MethodCallExpression m)
   at System.Linq.EnumerableExecutor`1.Execute()
   at Sitecore.ContentSearch.Linq.QueryableExtensions.GetResults[TSource](IQueryable`1 source)
   at Foundation.TagAndFilter.Repositories.FilterSearchRepository.GetFilterTagItems(Item contextItem, Boolean extended)

",80005aad-0000-d900-b63f-84710c7967bb

I tried looking for a fix on the internet, but could not find the satisfactory solution. I also tried to have vanilla deployment for Sitecore but no luck.

But!!! After a long thought process, I decided to rebuild the index and it wooooooorked!!! After triggering complete index rebuild, the search components came to the page and exception get lost from the log file.

So, if you find such an exception in your environment, first give a try to index rebuild, and save time.