Should I use field datatypes when performing hard matches?

I am trying to understand if field datatypes add any value when the goal is to do hard matches.

For example, let's say I'd like to index

{
  "name": "Sophie",
  "age": "20"
}

What is the difference between using the type keyword or short if my goal is to do a term query?

Is there any benefit? Perpahs, space or speed?

You'll be able to do a term query on both, depends on the results you want, for example the range query behaves differently whether the field type is string or numeric.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#query-dsl-range-query

I am only interested in hard matches at the moment (no range queries for example). My main question is if there is any benefit in indexing the data as the "right" datatype when performing hard term searches.

If you are doing "hard matches" (do you mean filtering?), then it shouldn't matter if it's a keyword or a short.

BUT, would you create a database table with everything varchar(255)?

I am referring to exact matches. If I understood correctly, that's the goal of term queries?

BUT, would you create a database table with everything varchar(255)?

I understand what you mean. Could you please clarify if there is any gain when using the right data type?

EDIT : I found this information in the documentation that explain this question

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