I'm using Nest 2.2.0 and am trying to build a multimatch query as follows:
var searchQuery = new MultiMatchQuery()
{
Fields = Field<Product>(p=>p.SKUName, 2),
Query = "hello world"
};
When I run it however, it returns:
The non-generic type 'Nest.Field' cannot be used with type arguments.
I don't understand why I'm getting the error, since I've more or less taken this query straight from the documentation found at https://www.elastic.co/guide/en/elasticsearch/client/net-api/2.x/multi-match-usage.html#_object_initializer_syntax_example_35.
In case it matters, I've defined the Product as follows:
[ElasticsearchType(Name="product", IdProperty="Id")]
public class Product
{
[Nest.Number(Store = true)]
public int Id {get;set;}
[String(Name="name", Store = true, Index=FieldIndexOption.Analyzed)]
public string SKUName { get; set; }
}
Is anyone able to help?
The Field
type you're looking for is Nest.Infer.Field
var searchQuery = new MultiMatchQuery()
{
Fields = Nest.Infer.Field<Product>(p => p.SKUName, 2),
Query = "hello world"
};
client.Search<Product>(new SearchRequest { Query = searchQuery });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With