Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New model field added to index, but doesn't appear in Solr #356

Closed
muppsy007 opened this issue Feb 24, 2024 · 1 comment
Closed

New model field added to index, but doesn't appear in Solr #356

muppsy007 opened this issue Feb 24, 2024 · 1 comment

Comments

@muppsy007
Copy link

I have inherited an older Silverstripe 3.7 site, running version 2.5 of this module. Working well.

This model that the Index uses is being extended to have a new field called "Hidden".

class Tour extends Product
{
    private static $db = [
        'TourName' => 'Varchar(50)',
        'TourDescription' => 'HTMLText',
        'TourLengthDays' => 'Int',
        'Hidden' => 'Boolean',  // <--- New field added
    ];
}

I have added this new field to the existing Index:

class TourIndex extends SolrIndex {
    function init() {
        $this->addClass('Tour');

        // Fields for searching
        $this->addFulltextField('TourName');
        $this->addFulltextField('TourDescription');

        // Fields we filter on
        $this->addFilterField('TourLengthDays', 'Int');
        $this->addFilterField('Hidden', 'Boolean');
    }
}

I then run the following process:

  1. Delete public_html/.solr
  2. sake /dev/tasks/Solr_Configure
  3. sake /dev/tasks/Solr_Reindex

No errors on either task. Output from both looks as it usually does. However when I look at the Schema Browser in Solr, Hidden is not present. Same thing if I manually open ./solr/TourIndex/conf/schema.xml. The new field is just not there. I have tried changing the type passed to $this->addFilterField('Hidden', 'Int'); but no difference.

Am I missing a step? I can't see another config file relating to existing fields anywhere.

@muppsy007
Copy link
Author

Update: I stepped debugged Solr_Configure locally and I see it using renderWith() on schema.ss. When I inspect the string in that, it most definately shows the new field being added.

<field name='VivaTour_TourLengthDays' type='tint' indexed='true' stored='true' multiValued=''/>
<field name='VivaTour_Hidden' type='boolean' indexed='true' stored='true' multiValued=''/>

But it doesn't appear in the final schema.xml when running the task on Production. But I was running the commands via CLI instead of browser. When I repeated the process and ran them in browser, the index was all good. I imagine a template cache thing between CLI and Browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant