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.
Adding the leading element |
Procedure
-
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 fields.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.
-
Verify the pending changes:
DESCRIBE PENDING SEARCH INDEX SCHEMA ON [<keyspace_name>.]<table_name>;
-
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.
-
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.