As from Tridion Docs 15, dynamic metadata fields can take a type field, specifying the data type of the field. Because a Schema can have multiple metadata fields with the same name but a different type, specifying type in your queries is recommended. However, if you choose not to set the type field, its value is assumed to be ANY, meaning it will match a field with the name you specify, regardless of its type.
Procedure
- If you have updated your queries to not use the "+" symbol anymore (recommended), then specify the type of the metadata field in an additional field called
type. That is, transform a query of the form
search (
criteria: {
metadataField {
keys: ["KEY1", "KEY2"],
value: "VALUE"
}
}
)
where
KEY1 and
KEY2 are metadata field names, and
VALUE is the text to search, into a query of the form
search (
criteria: {
metadataField {
keys: ["KEY1", "KEY2"],
value: "VALUE",
type: TYPE
}
}
)
where the added value
TYPE is one of the following, corresponding to the type of the metadata field you are querying:
DATE
DOUBLE
LONG
TEXT
ANY
If you specify the value ANY, the other five types are queried, which entails a slight performance hit.
Example of old query:
search (
criteria: {
metadataField: {
keys: ["summary", "body"],
value: "manufacturing"
}
}
)
Example of new query:
search (
criteria: {
metadataField: {
keys: ["summary", "body"],
value: "manufacturing",
type: TEXT
}
}
)
- Alternatively, if you are still using metadata field queries using the "+" symbol, then change the
dynamic or dynamic_not_indexed part of the metadata field name to dynamicTYPE or dynamicNotIndexedTYPE, respectively, where TYPE indicates the type of the field. That is, transform a query of the form
search(
criteria:{
field:{
key: "dynamic+KEY",
value: "VALUE"
}
}
)
where
KEY is the name of the metadata field and
VALUE is the text to search for, into a query of the form
search(
criteria:{
field:{
key: "dynamicTYPE+KEY",
value: "VALUE"
}
}
)
Example of old query:
search (
criteria: {
field: {
key:"dynamic+country",
value: "Bulgaria"
}
}
)
Example of new query:
search (
criteria: {
field: {
key: "dynamicText+country",
value: "Bulgaria"
}
}
)
Example of old query:
search (
criteria: {
field: {
key:"dynamic_not_indexed+state",
value: "Kansas"
}
}
)
Example of new query:
search (
criteria: {
field: {
key: "dynamicNotIndexedText+state",
value: "Kansas"
}
}
)