Changes a search schema for DSE Search.

Modify the search index pending schema.

Use the RELOAD SEARCH INDEX command to apply changes to the active schema.

See Managing search indexes.

Note: Space saving profiles apply only to the initial creation of the search index. For example, if the index was created using the spaceSavingNoTextfield and later a text column is added to the index using the ALTER command, the field type is set to TextField (not StrField).
Restriction: Command available only on DSE Search nodes. Running search index management commands on a large datasets may take longer than the CQLSH default timeout of 10 minutes, increase the CQLSH client timeout as required.

See Quick Start for CQL index management.


ALTER SEARCH INDEX SCHEMA ON [keyspace_name.]table_name
   (ADD field column_name
   | ADD element_path [attribute_list] WITH $$ json_map $$   
   | SET  element_identifier = 'value'
   | DROP field field_name
   | DROP element_identifier )
Table 1. Legend
Syntax conventions Description
UPPERCASE Literal keyword.
Lowercase Not literal.
Italics Variable value. Replace with a user-defined value.
[] Optional. Square brackets ( [] ) surround optional command arguments. Do not type the square brackets.
( ) Group. Parentheses ( ( ) ) identify a group to choose from. Do not type the parentheses.
| Or. A vertical bar ( | ) separates alternative elements. Type any one of the elements. Do not type the vertical bar.
... Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.
'Literal string' Single quotation ( ' ) marks must surround literal strings in CQL statements. Use single quotation marks to preserve upper case.
{ key : value } Map collection. Braces ( { } ) enclose map collections or key value pairs. A colon separates the key and the value.
<datatype1,datatype2> Set, list, map, or tuple. Angle brackets ( < > ) enclose data types in a set, list, map, or tuple. Separate the data types with a comma.
cql_statement; End CQL statement. A semicolon ( ; ) terminates all CQL statements.
[--] Separate the command line options from the command arguments with two hyphens ( -- ). This syntax is useful when arguments might be mistaken for command line options.
' <schema> ... </schema> ' Search CQL only: Single quotation marks ( ' ) surround an entire XML schema declaration.
@xml_entity='xml_entity_type' Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files.
Identifies the table of the search index; keyspace name is required when the table is not in the active keyspace.
Identifies a table column. The search index field and associated type are automatically defined.
Identifies the XML path to the setting. Separate child elements using a period. For example:
A comma separated list of attributes value pairs enclosed in braces using the following syntax:
[@attribute_name = 'value', 
@attribute_name = 'value', ... ]
Advanced. Use JSON format to define child elements, such as analyzer tokenizer and filter definitions of field type.
{ "element_name" : [ 
                  { "child_element_name" : { "child_attribute_name" : "value" } } ,
                  { "child_element_name" : { "child_attribute_name" : "value" } }, ... ],
"element_name" : [ 
                  { "child_element_name" : { "child_attribute_name" : "value" } } ,
                  { "child_element_name" : { "child_attribute_name" : "value" } }, ... ], ... }
Identifies the XML path to the setting. To locate an element with specific attribute, use the following syntax.
Insert a new type, field, or other settings in the pending schema.
Remove a table column that corresponds directly to a field or one of the following configurations from the pending schema. The required attributes by element are:
  • field - name attribute
  • fieldType - name attribute
  • dynamicField - name attribute
  • copyField - source and dest
See Managing search index fields.
Change the configuration of a setting in the pending schema.


EBNF syntax:
alterSearchIndex ::= 'ALTER' 'SEARCH' 'INDEX' 'SCHEMA'
          'ON' tableName
          ('ADD' elementPath 'WITH' json) |
          ('ADD' 'FIELD' fieldName) |
          ('SET' elementPath('@' attribute)? '=' value) |
          ('DROP' elementPath('@' attribute)?) |
          ('DROP' 'FIELD' fieldName)
          tableName        ::= (keyspace '.')? table
          elementPath      ::= elementName 
          ('[' '@' attributeName '=' attributeValue 
          (',' '@' attributeName '=' attributeValue)* ']')?
          ( '.' elementName ('[' '@' attributeName '=' attributeValue 
          (',' '@' attributeName '=' attributeValue)* ']')?)*
Railroad diagram:
Figure: alterSearchIndex
Image shows a railroad diagram for the ALTER SEARCH INDEX search CQL command
Figure: tableName
Image shows a railroad diagram of tableName
Figure: elementPath
Image shows a railroad diagram of elementPath


The search index schema is altered for the wiki.solr keyspace and table, and the specified options.

Add a new field using the element path and attribute list

Fields that do not exist in the table can be added to index to combine multiple columns into a single indexed field for searches.
ADD fields.field[@name='fieldname', @type='StrField', @multiValued = 'true', @indexed='true'];

Add a table column to the index

Automatically creates a field definition and adds the field type if required for a field that is not already indexed.
ALTER SEARCH INDEX SCHEMA ON demo.health_data ADD FIELD ethnicity;

Change a field name

DSE maps CQL columns to search index fields by matching the column name to the field name. Use unmapped fields for copy fields. If the field does not already exist it is added.

ALTER SEARCH INDEX SCHEMA ON wiki.solr SET field[@name='fieldname']@name = 'anotherFieldName';

Change the field type

ALTER SEARCH INDEX SCHEMA ON wiki.solr SET field[@name='fieldname']@type = 'StrField';

Drop a field

ALTER SEARCH INDEX SCHEMA ON wiki.solr DROP field fieldname;

Add a copy field

ALTER SEARCH INDEX SCHEMA ON wiki.solr ADD copyField[@source='sourcefield',@dest='destfield'];
Note: Both the source and destination field must be defined.