Using dynamic fields

Using dynamic fields, you can index content in fields that are not explicitly defined by the schema. A common use case for dynamic fields is to identify fields that should not be indexed or to implement a schema-less index.

Using dynamic fields, you can index content in fields that are not explicitly defined by the schema. Using dynamic fields, you can also process multiple Solr fields the same way. Use a generic prefix or suffix to reference the field. A common use case for dynamic fields is to catch fields that should not be indexed or to implement a schema-less index. As previously mentioned, in CQL-based Solr cores Solr schema fields that are dynamic and multivalued are not supported.

To use a dynamic field:

  • Include a Solr dynamic field in the schema.xml.

    Name the field using wildcard at the beginning or end of the field. For example, an asterisk prefix or suffix in the field name in the schema designates a dynamic field.

    • dyna_*
    • *_s
  • In CQL, to define the map collection column, use the same base name (no asterisk) as you used for the field in the schema.xml.

    For example, use dyna_* in the schema.xml and dyna_ for the name of the CQL map collection.

  • Use type text for the map key. For example:

    CREATE TABLE my_dynamic_table (
      . . .
      dyna_ map<text, int>,
      . . .
    );
  • Using CQL, insert data into the map using the base name as a prefix or suffix in the first component of each map pair. The format of the map using a prefix is:

    { prefix_literal : literal, prefix_literal : literal, . . . }

    For example, the CQL map looks like this:
    'dyn_' : {dyn_1 : 1, dyn_2 : 2, dyn_3 : 3}
    DSE Search maps the Solr dynamic field to a Cassandra map collection column, as shown in the advanced tutorial.