Swap Indexes Based On Domain

  • inclind
    Participant
    1 week, 4 days ago #44165

    I have two indexes set up (test and prod). I want to swap the index used for searching and indexing based on environment variables that are available to me. Is there a filter or some method available for me to do that?

    wpsolr
    Keymaster
    1 week, 4 days ago #44166

    I think so.

    use wpsolr\core\classes\WPSOLR_Events;
    
    add_filter( WPSOLR_Events::WPSOLR_FILTER_SEARCH_GET_DEFAULT_SOLR_INDEX_INDICE, 'get_default_solr_index_indice', 10, 2 );
    
    function get_default_solr_index_indice( $solr_index_indice, $language_code ) {
      return 'FF415A1D520A9C4EBB31DC6F18E4A12C'; // UUID of the index. You can find it in the url parameter of your index settings
    }
    inclind
    Participant
    1 week, 3 days ago #44205

    That seems to work for search and content updates. It doesn’t seem to affect where content is sent on screen #3 in the settings / I still have to make sure I’ve clicked on the correct one. Anyway, to conditionally lock that down to a specific index as well?

    wpsolr
    Keymaster
    1 week, 3 days ago #44210

    It is not possible.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.