Disable joins

Disable join on a search index by setting the _partitionKey field attributes indexed and docValues to false in the schema.

Procedure

  1. Verify if schema has the field _partitionKey and fieldType StrField definitions.

    DESCRIBE ACTIVE SEARCH INDEX SCHEMA ON wiki.solr;

    The example search index has joins enabled with no _partitionKey definition:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <schema name="autoSolrSchema" version="1.5">
      <types>
        <fieldType class="org.apache.solr.schema.TextField" name="TextField">
          <analyzer>
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
        </fieldType>
        <fieldType class="org.apache.solr.schema.TrieDateField" name="TrieDateField"/>
        <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
      </types>
      <fields>
        <field indexed="true" multiValued="false" name="body" stored="true" type="TextField"/>
        <field docValues="true" indexed="true" multiValued="false" name="real_date" stored="true" type="TrieDateField"/>
        <field indexed="true" multiValued="false" name="title" stored="true" type="TextField"/>
        <field indexed="true" multiValued="false" name="id" stored="true" type="StrField"/>
        <field indexed="true" multiValued="false" name="date" stored="true" type="TextField"/>
      </fields>
      <uniqueKey>id</uniqueKey>
    </schema>
  2. If required, add the string type definition:

    ALTER SEARCH INDEX SCHEMA ON wiki.solr
    ADD types.fieldType[@class='org.apache.solr.schema.StrField', @name='StrField'];

    The definition is added to the pending schema and is not immediately applied.

  3. Define the partition key field:

    • If the search index already has the partition key field, change the indexed and docValues to false:

      ALTER SEARCH INDEX SCHEMA ON wiki.solr
      SET field[@name='_partitionKey']@docValues='false';
      ALTER SEARCH INDEX SCHEMA ON wiki.solr
      SET field[@name='_partitionKey']@indexed='false';
    • If the schema does not have a _partitionKey definition, add one to override the default settings:

      ALTER SEARCH INDEX SCHEMA ON wiki.solr
      ADD fields.field[@name='_partitionKey', @type='StrField', @docValues='false', @indexed='false'];

      The type definition StrField is also required.

  4. Verify that the schema definition was correctly modified:

    DESCRIBE PENDING SEARCH INDEX SCHEMA ON wiki.solr;

    For example, a simple table with three fields and a single partition key:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <schema name="autoSolrSchema" version="1.5">
      <types>
        <fieldType class="org.apache.solr.schema.TextField" name="TextField">
          <analyzer>
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
        </fieldType>
        <fieldType class="org.apache.solr.schema.TrieDateField" name="TrieDateField"/>
        <fieldType class="org.apache.solr.schema.StrField" name="StrField"/>
      </types>
      <fields>
        <field indexed="true" multiValued="false" name="body" stored="true" type="TextField"/>
        <field docValues="true" indexed="true" multiValued="false" name="real_date" stored="true" type="TrieDateField"/>
        <field indexed="true" multiValued="false" name="title" stored="true" type="TextField"/>
        <field indexed="true" multiValued="false" name="id" stored="true" type="StrField"/>
        <field indexed="true" multiValued="false" name="date" stored="true" type="TextField"/>
        <field docValues="false" indexed="false" name="_partitionKey" type="StrField"/>
      </fields>
      <uniqueKey>id</uniqueKey>
    </schema>
  5. Reload the schema to make it active:

    RELOAD SEARCH INDEX ON wiki.solr;
  6. Optional, rebuild the search index:

    REBUILD SEARCH INDEX ON wiki.solr;
     Rebuilding from CQL regenerates the index from the existing data on all search nodes, which use significant resources and is not required when disabling joins.
    When no rebuild command is executed after a schema change, new data in the field is not be duplicated and indexed.
    Use https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/tools/dsetool/dsetoolRebuild_indexes.html[dsetool rebuild_indexes] to regenerate the index on a node-by-node basis.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com