MultiMatch Over Different Field Types Fails

If you have both number and string fields and you try and multimatch it , it will fail on the low level call. I am not sure if it fails on converting the string to the int for comparision or what. I assumed it would ignore that since a string "test" doesnt have a valid number to convert to

I have seen other questions with no answers. I do not want to convert all my fields to string to have it work correctly

https://discuss.elastic.co/t/help-with-elasticsearch-dsl-multimatch-not-working-with-searching-through-text-and-integer-doc-types-transport-error-400/104857/6

You can set lenient to true in your multi_match query to ignore exceptions caused by data-type mismatches:

GET my_index/_search
{
  "query": {
    "multi_match": {
      "query": "abc",
      "fields": ["a", "b"],
      "lenient": true
    }
  }
}

I have tried that running the latest version of ES and get the same 400 transport error as the user posted. Also looking at the doc it looks like by default lenient is set to true

I have tried with Lenient set to true and still get the same error

Here is what i have in my instance
"ticketName":{"type":"text","fields":{"keyword":{"type":"keyword","ignore_above":256}}},"ticketNumber":{"type":"long"}}

Here is my code block c#
var searchResponse = _client.Search<ES_Ticket>(s => s
.From(0)
.Size(10)
.Query(q => q
.MultiMatch(m => m
.Query("test")
.Fields(f => f.Field(p => p.ticketNumber).Field("ticketName"))
)
).Lenient(true)
);

Here is my result. As you can see exception is a 400

If my query is "123"
It works fine

Can you post a link to the documentation where it says that lenient defaults to 'true? I think that would be a mistake in the docs.

My C# is a bit rusty, but I think you may have a syntax error in your request. I think it should be:

var searchResponse = _client.Search<ES_Ticket>(s => s
.From(0)
.Size(10)
.Query(q => q
    .MultiMatch(m => m
        .Query("test")
        .Fields(f => f.Field(p => p.ticketNumber).Field("ticketName"))
        .Lenient(true)
        )
    )
);

Sorry that was a mistake on my end misread something

Thank you abdon !!
This was it had my lenient in the wrong place WHEW

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.