Closed muppsy007 closed 5 years ago
hi @muppsy007 - thanks for reporting. I was confused at first and this looked like a bug I've seen recently, however on closer look it is complaining about ClassHierarchy
not being defined - can you please confirm whether you have a field with this name on any object in your project (including vendor provided portions)?
It seems like perhaps there's a misconfiguration between the generated solr_config (schema.xml iirc), and the reality of the class structure.
Hi @NightJar - The only place I find it searching codebase is actually in the fulltextsearchmodule itself. I thought it might have been a standard field from an older version of Silverstripe that was deprecated.
But this just led me to something. The schema.xml that I is created by the Solr_Configure task. It's defined in there along with my custom index stuff.
<fields>
<field name='_documentid' type='string' indexed='true' stored='true' required='true' />
<field name='ID' type='tint' indexed='true' stored='true' required='true' />
<field name='ClassName' type='string' indexed='true' stored='true' required='true' />
<field name='ClassHierarchy' type='string' indexed='true' stored='true' required='true' multiValued='true' />
<field name='_text' type='htmltext' indexed='true' stored='true' multiValued='true' />
<field name='MyObject_CustomName' type='text' indexed='true' stored='true' multiValued=''/>
<field name='MyObject_CustomDescription' type='htmltext' indexed='true' stored='true' multiValued=''/>
<field name='_versionedstage' type='string' indexed='true' stored='true' multiValued=''/>
<field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
</fields>
I manually removed that field definition from the schema.xml, tried a dev/build, even a solr restart. Same error persists.
@NightJar On further tracing I found this is the culprit of my particular error:
// Delete all records which do not match the necessary classname rules
$conditions = array();
foreach ($classes as $class => $options) {
if ($options['include_children']) {
$conditions[] = "ClassHierarchy:{$class}";
} else {
$conditions[] = "ClassName:{$class}";
}
}
But it seems like a reliance everywhere on ClassHierarchy that isn't there. Like a mismatch between SS versions? (I can't find any docs on ClassHierarchy). I tried altering my Index config to index standard pages instead of custom objects to rule that out. But I get the same thing.
<?php
class MyIndex extends SolrIndex {
function init() {
$this->addClass('Page');
$this->addFulltextField('Title');
$this->addFulltextField('Content');
}
}
@NightJar I wonder if Solr just isn't picking up the generated schema.xml and that's what is being referred to as undefined? I just did a simple test search on another field that definately is in the ORM and defined in schema.xml, and I get the same error, but for that field:
$query = new SearchQuery();
$query->search('my query', null, ['MyObject_CustomName' => 1.5, 'MyObject_CustomDescription' => 1.0]);
$results = singleton('MyIndex')->search($query);
org.apache.solr.common.SolrException: undefined field MyObject_CustomName
The config is in docroot/.solr/MyIndex/schema.xml. Interestingly, Solr_Configure task cannot create the Index by itself. Spits out a 400. But if I create the core with the same name manually in Solr dashboard, Solr_Configure runs fine.
Interesting, thanks for adding this extra info @muppsy007
@NightJar This might be it. I found copying the generated conf from the above location to /var/solr/data/MyIndex and reloading the core gets some response from Solr, albeit more errors about unsupported modules and types.
What is the actual recommended version of Solr for the 2.x branch of this module? I don't see anything on the readme, however the standalone solr docs refer to 4.x. In fact, master docs refer to Solr 4.x in places too. Not sure if this is just inherited from old versions of the module, or the module only supports Solr 4.x.
@muppsy007 to my knowledge the module has only been tested (and thus "supported") on Solr 4 (which unfortunately is quite out of date). However there have been efforts to support more recent versions #226 #120 If I recall correctly, the only major blocker is that there has been limited testing. If you feel that there could be some improvements made to enable more support, please take a look and see if you could help any of the existing efforts :)
Do you think this issue is purely Solr version related?
Thanks @NightJar .
I had another go at this last night and managed to get a functioning search system after installing Solr 4.9.1. So I guess the issue here is an incompatibility between the module and more recent versions of Solr.
My functional version combo for future searches:
Thanks for your help.
Thanks for reporting back @muppsy007 !
Silverstripe version: 3.6 Fulltextsearch version: 2.4 or 2.2 Solr version: 6.6.6, 7.7.1, 8.0.0
I've tried multiple versions of Solr with the same result. I can't for the life of me get the following setup and snippet to work:
_config.php
/mysite/code/Search/MyIndex.php
/dev/tasks/Solr_Configure appears to work. (doesn't display anything aside from a title and creates a .solr directory with a subdir 'MyIndex' with a single conf directory containing xml and txt files). I can also visit the Solr admin fine. It's when I run either /dev/tasks/Solr_Reindex that I get a 400 Bad Request on screen, and the following output in log. What am I doing wrong?