I'm running into exactly the same problem described (and not answered) here ElasticSearch NEST Search
I use:
.NET Framework 4.5;
ASP.NET MVC 5;
Elasticsearch 1.6.0 (on a server);
Elasticsearch.NET 1.6.1
NEST 1.6.1
I have an MVC controller which has two actions:
Index - which contains HTML UI form
Search - which contains Elasticsearch.NET client and a query.
public ActionResult Search(SearchCreteria sc) { Settings settings = new Settings(); Client client = new Client(settings); ElasticsearchClient esClient = client.Get(); var test = esClient.Search<Contract>(body => body.Query(query => query.QueryString(qs => qs.Query("test")))); return View(test); }
Entire "body => body.Query(query => query.QueryString(qs => qs.Query("test")))" lambda expression in the code above has squiggly red underline with the following tooltip:
(Parameter) ? body
Error:
Cannot convert lambda expression to type 'object' because it is not a delegate type
I googled the problem and found out that in 99% of cases folks forgot to include an assembly, typically System.Linq.
Well.. I definitely didn't forget to add that one, but I though maybe I have to include a NEST specific assembly or something like that (which I'm sure is not true, except for NEST itself), so I decided to add everything I though could be somewhat relevant and I ended up with this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using WebUI.Models.Concrete;
using Domain.Concrete.Entities;
using Domain.Concrete.Connectivity.Elastic;
using Domain.Concrete.Processors.Elastic;
using Elasticsearch;
using Elasticsearch.Net;
using Elasticsearch.Net.Connection.Configuration;
using Elasticsearch.Net.Connection.RequestState;
using Elasticsearch.Net.Connection.Security;
using Elasticsearch.Net.ConnectionPool;
using Elasticsearch.Net.Exceptions;
using Elasticsearch.Net.Providers;
using Elasticsearch.Net.Serialization;
using Nest;
using Nest.Domain;
using Nest.DSL.Descriptors;
using Nest.DSL.Query;
using Nest.DSL.Query.Behaviour;
using Nest.DSL.Visitor;
using Nest.Resolvers.Converters.Aggregations;
using Nest.Resolvers.Converters.Filters;
using Nest.Resolvers.Converters.Queries;
using Nest.Resolvers.Writers;
It didn't help as expected, but was worth a try. So now, I'm not sure where is the problem and any help would be highly appreciated.