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

SearchVariantSubsites alterDefinition issue #107

Closed
timkung opened this issue Feb 11, 2016 · 9 comments
Closed

SearchVariantSubsites alterDefinition issue #107

timkung opened this issue Feb 11, 2016 · 9 comments
Assignees
Labels

Comments

@timkung
Copy link

timkung commented Feb 11, 2016

In the case where the silverstripe/subsites module is installed and there are multiple classes being indexed, e.g. both SiteTree and File, the alterDefinition method (and then ultimately the SolrIndex->_addAs() method) needs to be able to handle having the "_subsite" field added to multiple classes (in the case example mentioned above, both SiteTree and File).

The issue here is when Solr_Configure is called, it calls the SearchVariantSubsites->alterDefinition method for each of the classes, but each time it just overwrites the "base" and "origin" key to the class called, so only the last class added to the SolrIndex gets the "_subsite" field applied to it, e.g. If we add the "SiteTree" class to the SolrIndex and then the "File" class to the SolrIndex, only the "File" class ends up with the "_subsite" field (because of SolrIndex->_addAs() line 519 - if ($field['base'] == $base) {)

A couple of initial thoughts would be to either allow the $field['base'] value to be an array or it needs to set class specific fields for subsites (rather than the global "_subsite" field), e.g. go through the classes in the index and add {$Class}_SubsiteID to the respective Solr documents.

@tractorcow
Copy link

How about having a separate field for each class?

I.e. instead of $index->filterFields['_subsite'] = array( maybe $index->filterFields[$base . '_subsite'] = array( in SearchVariantSubsites?

@tractorcow
Copy link

On second thought, that would probably break a huge amount of things. :) Maybe the array-base is better, and we just make sure to merge any existing config for subsequent calls to alterDefinition.

This doesn't seem like an easy problem to solve...

@timkung
Copy link
Author

timkung commented Feb 11, 2016

Yes, definitely one that will require some decent planning =)

@tractorcow tractorcow self-assigned this Apr 15, 2016
@tractorcow
Copy link

We're fixing this now. :D Internal issue tracking: https://silverstripe.atlassian.net/browse/OSS-1737

@tractorcow
Copy link

I can confirm this doesn't just affect subsites, but also versioned.

@tractorcow
Copy link

I've tested a fix locally that seems to do the job... tractorcow@401afc5

Managed to do this without breaking changes. :)

Note that there is still only ONE field for all objects, but when adding objects multiple types may write to it. That way existing code that filters on that field won't break.

@madmatt
Copy link
Member

madmatt commented Apr 20, 2016

So this is fixed by still having a single _subsite field for example, which still only accepts a single int value - and the value might be overwritten by two different variants?

Makes sense for SearchVariantVersioned and SearchVariantSubsites, each document will only have one value for _subsite or _versionedstage.

@dhensby
Copy link
Contributor

dhensby commented Apr 5, 2018

@tractorcow so is this fixed?

@tractorcow
Copy link

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

No branches or pull requests

5 participants