# MultiMatch Over Different Field Types Fails

**URL:** <https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875>\
**Category:** Elasticsearch\
**Created:** [July 27, 2018, 5:49am UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875 "2018-07-27T05:49:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eskrew](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@eskrew](https://discuss.elastic.co/u/eskrew)\
**Post date:** [July 27, 2018, 5:49am UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/1 "2018-07-27T05:49:40Z")

</div>

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

> [@Numberformat exception](https://discuss.elastic.co/t/numberformat-exception/21804):
>
> I am indexing different type of fields that include number and strings. When I use multimatch queries (that includes both number and string fields) for terms such as "2001 camaro", I get NumberFormatException. I understand why this is happening but wondering if this can be avoided. Temporarily, I have fixed it by indexing all fields as strings instead of numbers. Example: Fields used : year (number) and model (string) multimatch cross type query includes both year and model. search query…

[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](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)

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [July 27, 2018, 10:22am UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/2 "2018-07-27T10:22:22Z")

</div>

You can set `lenient` to `true` in your multi\_match query to ignore exceptions caused by data-type mismatches:

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

```

---

<div class="post-metadata">

**Author:** ![eskrew](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@eskrew](https://discuss.elastic.co/u/eskrew)\
**Post date:** [July 27, 2018, 12:48pm UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/3 "2018-07-27T12:48:34Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/0/2057bf894ba36a6d9fe82bed30d48e7004d63b05.png)

If my query is "123"  
It works fine

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [July 27, 2018, 1:27pm UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/4 "2018-07-27T13:27:54Z")

</div>

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:

```auto
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)
        )
    )
);

```

---

<div class="post-metadata">

**Author:** ![eskrew](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@eskrew](https://discuss.elastic.co/u/eskrew)\
**Post date:** [July 27, 2018, 3:40pm UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/5 "2018-07-27T15:40:57Z")

</div>

Sorry that was a mistake on my end misread something

---

<div class="post-metadata">

**Author:** ![eskrew](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@eskrew](https://discuss.elastic.co/u/eskrew)\
**Post date:** [July 27, 2018, 3:48pm UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/6 "2018-07-27T15:48:31Z")

</div>

> [@abdon](#):
>
> 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) ) ) );

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 24, 2018, 3:48pm UTC](https://discuss.elastic.co/t/multimatch-over-different-field-types-fails/141875/7 "2018-08-24T15:48:32Z")

</div>

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