ALTER SEARCH INDEX SCHEMA
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.
spaceSavingNoTextfield
and
later a text column is added to the index using the ALTER command, the field type is set to
TextField
(not StrField). Synopsis
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 ) ;
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. |
- Variables
- keyspace_name.table_name
- Identifies the table of the search index; keyspace name is required when the table is not in the active keyspace.
- column_name
- Identifies a table column. The search index field and associated type are automatically defined.
- element_path
- Identifies the XML path to the setting. Separate child elements using a period. For
example:
types.fieldTypes
- attribute_list
- A comma separated list of attributes value pairs enclosed in braces using the
following
syntax:
[@attribute_name = 'value', @attribute_name = 'value', ... ]
- json_map
- 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" } }, ... ], ... }
- element_identifier
- Identifies the XML path to the setting. To locate an element with specific attribute,
use the following syntax.
element_name[@attribute_name='value']
- ADD
- Insert a new type, field, or other settings in the pending schema.
- DROP
- 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
attributefieldType
-name
attributedynamicField
-name
attributecopyField
-source
anddest
- SET
- Change the configuration of a setting in the pending schema.
EBNF
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)* ']')?)*




Examples
This section shows some simple search index examples for the wiki.solr keyspace and table, and demo.health_data.
For extensive information and examples on search indexes, including adding and dropping search index fields, field types, field classes, tuples, UDTs, and map columns, see Managing search index fields.
You must add the search index before you can alter it.
Add a new field using the element path and attribute list
ALTER SEARCH INDEX SCHEMA ON wiki.solr ADD fields.field[@name='fieldname', @type='StrField', @multiValued = 'true', @indexed='true'];
Add a table column to the index
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='sourcefieldname', @dest='destfieldname'];
Add a field type
Set the class for the field type in @class
and the name of the field
type in @name
. The following example adds a string field type named
stringtype
.
ALTER SEARCH INDEX SCHEMA ON wiki.solr ADD types.fieldtype[@class='org.apache.solr.schema.StrField', @name='stringtype'];
Drop a field type
ALTER SEARCH INDEX SCHEMA ON wiki.solr DROP types.fieldtype[@name='typename'];
Add a text field
To add a text field, two commands are required:
ALTER SEARCH INDEX SCHEMA ON wiki.solr SET types.fieldType[@name='TextField']@class='org.apache.solr.schema.TextField';
ALTER SEARCH INDEX SCHEMA ON wiki.solr SET fields.field[@name='fieldname']@type='TextField';
Add a dynamic field
ALTER SEARCH INDEX SCHEMA ON wiki.solr ADD dynamicField[@name='*fieldname', @type='TextField'];