Adding a column to the index

Add a table column to the index. Field types are inferred when fields are added. The field types are added if they do not exist in the schema. Field type names are generated using the field type name as the simple name of the field type.

Procedure

  1. Add a table column to the index:

    • Add a regular column

      For example, to add a field to the wiki demo index:

      ALTER TABLE wiki.solr ADD intfield int;
      ALTER SEARCH INDEX SCHEMA ON wiki.solr ADD field intfield;

      Adds the following field:

      <field indexed="true" multiValued="false" name="intfield" stored="true" type="TrieIntField" />

      And the following field type:

      <fieldType name="TrieIntField" class="org.apache.solr.schema.TrieIntField"/>
    • Add a table column that is a Tuple or UDT

      Tuple columns are added as multiple fields:

      ALTER TABLE solr.wiki ADD fieldname tuple<text,int>;
      ALTER SEARCH INDEX SCHEMA ON solr.wiki ADD fields.field fieldname;

      Adds the following to the schema:

      <field indexed="true" multiValued="false" name="fieldname" stored="true" type="TupleField" />
               <field indexed="true" multiValued="false" name="fieldname.field1" stored="true" type="TextField" />
               <field indexed="true" multiValued="false" name="fieldname.field2" stored="true" type="TrieIntField" />

      Adding the leading element fields. in ADD fields.field fieldname is optional and provides only cosmetic structure.

  2. Verify the pending changes:

    DESCRIBE PENDING SEARCH INDEX SCHEMA ON [keyspace_name.]table_name;
  3. Activate the changes:

    RELOAD SEARCH INDEX ON [keyspace_name.]table_name;

    Copies the pending schema over the active schema. New transactions, such as data inserted into the table, are processed using the active schema. The existing data is not effected by a schema change.

  4. Rebuild the index:

    REBUILD SEARCH INDEX ON [keyspace_name.]table_name;

    The REBUILD SEARCH INDEX regenerates the index using existing data. Rebuilding is required when changing the way that data is indexed, such as changing the type of field or if a field is added to the index.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com