ALTER SEARCH INDEX CONFIG
Modify the search index pending configuration.
Use the CQL shell command DESCRIBE SEARCH INDEX to view the pending and active search index. Use the RELOAD SEARCH INDEX command to apply changes to the active configuration.
Restriction: Command available only on DSE Search nodes. Running search index management commands on large datasets can take longer than the CQLSH default timeout of 10 minutes. Increase the CQLSH client timeout as required.
Synopsis
ALTER SEARCH INDEX CONFIG ON [<keyspace_name>]<table_name> ( ADD <element_path> [ <attribute_list> ] WITH $$ <json_map> $$ | SET <element_identifier> = '<value>' | SET <shortcut> = <value> | DROP <element_identifier> | DROP <shortcut> ) ;
Syntax legend
Syntax conventions | Description |
---|---|
UPPERCASE |
Literal keyword. |
Lowercase |
Not literal. |
|
Variable value. Replace with a user-defined value. |
|
Optional.
Square brackets ( |
|
Group.
Parentheses ( |
|
Or.
A vertical bar ( |
|
Repeatable.
An ellipsis ( |
|
Single quotation ( |
|
Map collection.
Braces ( |
Set, list, map, or tuple.
Angle brackets ( |
|
|
End CQL statement.
A semicolon ( |
|
Separate the command line options from the command arguments with two hyphens ( |
|
Search CQL only: Single quotation marks ( |
|
Search CQL only: Identify the entity and literal value to overwrite the XML element in the schema and solrConfig files. |
- keyspace_name.table_name
-
Identifies the table of the search index; keyspace name is required when the table is not in the active keyspace.
- 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>']
- shortcut
-
Shortcuts to configuration element values using SET:
-
autoCommitTime
Default value is 10000. -
defaultQueryField
Name of the field. Default not set.Use SET to add. Use DROP to remove.
-
directoryFactory
Can be used as an alternative to the directoryFactoryClass option. The options are:-
'standard'
-
'encrypted'
-
-
filterCacheLowWaterMark
Default is 1024. -
filterCacheHighWaterMark
Default is 2048. -
directoryFactoryClass
Specifies the fully-qualified name of the directory factory. Use in place of the directoryFactory option for directory factories other than the standard or encrypted directory factory. -
mergeMaxThreadCount
Must configure with mergeMaxMergeCount. The default is the number of tpc_cores as configured in cassandra.yaml. -
mergeMaxMergeCount
Must configure with mergeMaxThreadCount. The default calculated value is:max(max(<maxThreadCount * 2>, <<num_tokens> * 8>), <maxThreadCount + 5>)
where num_tokens is the number of token ranges to assign to the virtual node (vnode) as configured in cassandra.yaml.
-
ramBufferSize
Default is 512. -
realtime
Default is false.
-
EBNF
EBNF syntax:
alterSearchIndex ::= 'ALTER' 'SEARCH' 'INDEX' 'CONFIG' 'ON' tableName ( ('ADD' elementPath 'WITH' json) | ('SET' elementPath('@' attribute)? '=' value) | ('DROP' elementPath('@' attribute)?) | ) tableName ::= (keyspace '.')? table elementPath ::= elementName ('[' '@' attributeName '=' attributeValue (',' '@' attributeName '=' attributeValue)* ']')? ( '.' elementName ('[' '@' attributeName '=' attributeValue (',' '@' attributeName '=' attributeValue)* ']')?)*
Railroad diagram:
Examples
The search index configuration is altered for the wiki.solr keyspace and table, and the specified options.
Enable encryption on search index
Enable encryption on search index:
-
Change the configuration schema:
ALTER SEARCH INDEX CONFIG ON cycling.comments SET directoryFactory = 'encrypted';
-
Verify the change is correct in the pending schema:
DESC PENDING SEARCH INDEX CONFIG ON cycling.comments;
-
Make the configuration active:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <config> <luceneMatchVersion>LUCENE_6_0_1</luceneMatchVersion> <dseTypeMappingVersion>2</dseTypeMappingVersion> <directoryFactory class="solr.EncryptedFSDirectoryFactory" name="DirectoryFactory"/> <indexConfig> <rt>false</rt> </indexConfig> <jmx/> <updateHandler> <autoSoftCommit> <maxTime>10000</maxTime> </autoSoftCommit> </updateHandler> <query> <filterCache class="solr.SolrFilterCache" highWaterMarkMB="2048" lowWaterMarkMB="1024"/> <enableLazyFieldLoading>true</enableLazyFieldLoading> <useColdSearcher>true</useColdSearcher> <maxWarmingSearchers>16</maxWarmingSearchers> </query> <requestDispatcher> <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048000"/> <httpCaching never304="true"/> </requestDispatcher> <requestHandler class="solr.SearchHandler" default="true" name="search"/> <requestHandler class="com.datastax.bdp.search.solr.handler.component.CqlSearchHandler" name="solr_query"/> <requestHandler class="solr.UpdateRequestHandler" name="/update"/> <requestHandler class="solr.UpdateRequestHandler" name="/update/csv" startup="lazy"/> <requestHandler class="solr.UpdateRequestHandler" name="/update/json" startup="lazy"/> <requestHandler class="solr.FieldAnalysisRequestHandler" name="/analysis/field" startup="lazy"/> <requestHandler class="solr.DocumentAnalysisRequestHandler" name="/analysis/document" startup="lazy"/> <requestHandler class="solr.admin.AdminHandlers" name="/admin/"/> <requestHandler class="solr.PingRequestHandler" name="/admin/ping"> <lst name="invariants"> <str name="qt">search</str> <str name="q">solrpingquery</str> </lst> <lst name="defaults"> <str name="echoParams">all</str> </lst> </requestHandler> <requestHandler class="solr.DumpRequestHandler" name="/debug/dump"> <lst name="defaults"> <str name="echoParams">explicit</str> <str name="echoHandler">true</str> </lst> </requestHandler> </config>
-
Apply the configuration and rebuild the index:
RELOAD SEARCH INDEX ON cycling.comments;
Auto soft commit max time
To set index configuration with shortcut for automatic soft commit max time to 10000ms:
ALTER TABLE cycling.comments WITH caching = {
'keys' : 'NONE',
'rows_per_partition' : 10
};
Make the pending changes active (use DESCRIBE SEARCH INDEX to review changes):
RELOAD SEARCH INDEX ON cycling.comments;
Request handler
Add a configuration request handler
ALTER SEARCH INDEX CONFIG ON cycling.comments
ADD requestHandler[@name='/elevate',@class='solr.SearchHandler', @startup='lazy']
WITH $$ {"defaults":[{"echoParams":"explicit"}],"last-components":["elevator"]} $$;
Reload the search index:
RELOAD SEARCH INDEX ON cycling.comments;
which adds the requestHandler element to the config:
<requestHandler name="/elevate" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</int>
</lst>
<arr name="last-components">
<str>elevator</str>
</arr>
</requestHandler>
To extend TieredMergePolicy to support automatic removal of deletes:
ALTER SEARCH INDEX CONFIG ON cycling.comments
SET indexConfig.mergePolicyFactory[@class='org.apache.solr.index.AutoExpungeDeletesTieredMergePolicyFactory'].bool[@name='mergeSingleSegments'] = true;
ALTER SEARCH INDEX CONFIG ON cycling.comments
SET indexConfig.mergePolicyFactory[@class='org.apache.solr.index.AutoExpungeDeletesTieredMergePolicyFactory'].int[@name='maxMergedSegmentMB'] = 1005;
ALTER SEARCH INDEX CONFIG ON cycling.comments
SET indexConfig.mergePolicyFactory[@class='org.apache.solr.index.AutoExpungeDeletesTieredMergePolicyFactory'].int[@name='forceMergeDeletesPctAllowed'] = 25;
Reload the search index:
RELOAD SEARCH INDEX ON cycling.comments;
Change the auto-commit time
To change the automatic commit time, ALTER SEARCH INDEX CONFIG. For example:
ALTER SEARCH INDEX CONFIG ON cycling.comments
SET autoCommitTime = 1000;