Skip to main content

Exercises: token type

Refer back to the string section above for details on configuring the token field type.

equals on strings​

πŸ”— Playground link: equals on string mismatch

The category field is a string. Try using the string field type - why doesn't it work? What's the right type to use in order to use the equals operator?

Solution

The token type must be manually/statically mapped; it is not dynamically mapped.

{
"mappings": {
"dynamic": true,
"fields": {
"category": [
{
"type": "token"
}
]
}
}
}

πŸ”— token type equals fixed

in and range on strings​

Similarly, the token field type is needed to do in and range queries on exact strings.