Elasticsearch.Net Error: match query does not support multiple fields

  • Thread starter Thread starter kobosh3
  • Start date Start date
K

kobosh3

Guest
I am following through with this. I am trying to search index "people" which I successfully indexed into Elasticsearch version 7.6.2 cluster on my windows 10. I created web api ( .Net Framework 4.7.2 ) installed Elasticsearch.Net and NEST ( v 7.6.1) from Nuget. The Get method throws exception as shown:

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">

{"error":{"root_cause":[{"type":"parsing_exception","reason":"[match] query doesn't support multiple fields, found [field] and [query]","line":1,"col":67}],"type":"parsing_exception","reason":"[match] query doesn't support multiple fields, found [field] and [query]","line":1,"col":67},"status":400}

</string>

I can run search in Kibana without error.

public class ValuesController : ApiController
{

Uri uris = new Uri("http://localhost:9200");
ElasticLowLevelClient lowlevelClient;
object[] people = new object[]
{
new { index = new { _index = "people", _type = "person", _id = "1" }},
new { FirstName = "Martijn", LastName = "Laarman" },
new { index = new { _index = "people", _type = "person", _id = "2" }},
new { FirstName = "Greg", LastName = "Marzouka" },
new { index = new { _index = "people", _type = "person", _id = "3" }},
new { FirstName = "Russ", LastName = "Cam" },
};


public ValuesController()
{
var settings = new ConnectionConfiguration(uris)
.RequestTimeout(TimeSpan.FromMinutes(2));
lowlevelClient = new ElasticLowLevelClient(settings);

}

// GET api/values/5
public string Get()
{
var searchResponse = lowlevelClient.Search<StringResponse>("people", PostData.Serializable(new
{
from = 0,
size = 10,
query = new
{
match = new
{
field = "firstName",
query = "Martijn"
}
}
}));

var successful = searchResponse.Success;//false
var responseJson = searchResponse.Body;

return responseJson;
}





Continue reading...
 
Back
Top