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

  • Question

  •  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;
            }
             


    • Edited by kobosh3 Tuesday, April 14, 2020 4:48 AM
    • Moved by CoolDadTx Tuesday, April 14, 2020 1:40 PM Third Party Product
    Tuesday, April 14, 2020 4:34 AM

Answers

  • Hi kobosh3,

    Thank you for posting here.

    This thread is mainly about Elasticsearch.Net, many people here may not have experienced using it.

    So I suggest you can ask your question on Github. They know Elasticsearch.Net better.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by kobosh3 Thursday, April 16, 2020 12:20 AM
    Tuesday, April 14, 2020 6:48 AM