NEST version: NEST.2.1.1
Elastic Search Version : Elasticsearch 2.3.1
I have a query like below.
{
"size" : 10,
"query" : {
"match" : {
"bodyContent" : "singapore"
}
}
}
I converted it into a string.
string query = @{
""size"" : 10,
""query"" : {
""match"" : {
""bodyContent"" : ""singapore""
}
}
};
then im sending this as a parameter.
var result = client.Search<Class1>(s => s
.From(0)
.Size(10)
.QueryRaw(query)
);
But the compiler says it Class1 doesnt contain QueryRaw.
Class1.
public class Class1
{
[JsonProperty("key")]
public string key { get; set; }
[JsonProperty("doc_count")]
public int doc_count { get; set; }
}
Can you please help me in solving this.
Russcam reply:
There is no QueryRaw in NEST 2.x (as the compiler indicates ). You can use .Raw() on QueryContainerDescriptor
client.Search<Class1>(s => s
.Size(10)
.Query(q => q
.Raw(@"{
""match"" : {
""bodyContent"" : ""singapore""
}
}")
)
);
Note that this is only the query element of the query, so .From() and .Size() etc need to be set outside.
i tried to modify my code after the suggestion given by Russ. But still, im getting the same error.
Modified code:
var result = client.Search<Class1>(s => s
.From(0)
.Size(100)
.Query(q => q
.Raw(query)
)
);
output: INVALID NEST RESPONSE BUILT FROM AN UNSUCCESSFUL LOW LEVEL CALL ON POST.
But if the call is made without any query(similar to below code), the output says VALID NEST RESPONSE BUILT FROM A SUCCESSFUL LOW LEVEL CALL ON POST
var res = client.Search<Class1>();