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.
spaceSavingSlowTriePrecision
, and later a numeric column is added to the
index using the ALTER command, the trie fields precisionStep of the new column is not set to
'0'. 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
The search index schema is altered for the cycling.comments
keyspace and
table, and the specified options.
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
fields.
in ADD fields.field
fieldname
is optional and
provides only cosmetic structure.ALTER SEARCH INDEX SCHEMA ON cycling.comments ADD fields.field[@name='fieldname', @type='StrField', @multiValued = 'false', @indexed='true'];
RELOAD SEARCH INDEX ON cycling.comments;
Add a table column to the index
ALTER SEARCH INDEX SCHEMA ON cycling.comments ADD FIELD record_id;
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Change a field name
ALTER SEARCH INDEX SCHEMA ON cycling.comments SET field[@name='fieldname']@name = 'anotherFieldName';
To apply the schema changes:
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Change the field type
ALTER SEARCH INDEX SCHEMA ON cycling.comments SET field[@name='fieldname']@type = 'UUIDField';
To apply the schema changes:
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Drop a field
ALTER SEARCH INDEX SCHEMA ON cycling.comments DROP field anotherFieldName;
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Set a field type and a text field
The first command sets the TextField
type, which is required for the second
command that sets the text field:
ALTER SEARCH INDEX SCHEMA ON cycling.comments SET types.fieldType[@name='TextField']@class='org.apache.solr.schema.TextField'; ALTER SEARCH INDEX SCHEMA ON cycling.comments SET fields.field[@name='comment']@type='TextField';
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Drop a field and a field type
The first command drops the field from the search index and the second command drops the field type:
ALTER SEARCH INDEX SCHEMA ON cycling.comments DROP field comment; ALTER SEARCH INDEX SCHEMA ON cycling.comments DROP types.fieldType[@name='TextField'];
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;
Add a field type and a dynamic field
The first command adds the TextField
type, which must exist before the
dynamic field is added by the second command:
ALTER SEARCH INDEX SCHEMA ON cycling.comments ADD types.fieldType[@class='org.apache.solr.schema.TextField', @name='TextField'] WITH '{"analyzer":{"class":"org.apache.lucene.analysis.standard.StandardAnalyzer"}}'; ALTER SEARCH INDEX SCHEMA ON cycling.comments ADD dynamicField[@name='*fieldname', @type='TextField'];
RELOAD SEARCH INDEX ON cycling.comments; REBUILD SEARCH INDEX ON cycling.comments;