*** VERY IMPORTANT UPDATE ***
Anyone using SimpleSearch.Solr, be warned:
SOLR NO LONGER USES SCHEMA.XML. The SimpleSearch documentation NEEDS to be updated. I spent a good 3-4 days trying to figure this bloody thing out and all along my changes to schema.xml were doing absolutely nothing! It now uses managed-schema. Wish I had known that from the start...
Anyways, rant over. There are still lots of issues with the SimpleSearch.Solr. Using the solr.logs, I've found quite a few problems in the query that actually gets sent to Solr which results in zero results. For example (from simplesearchdriversolr.class.php):
/* add fields to search
$fields = $this->modx->getFields('modResource');
foreach ($fields as $fieldName => $default) {
$query->addField($fieldName);
} */
Generates a HUGE list of fields to search, and when these aren't properly shown in the managed-schema (which they weren't), you get the "Error running query on Solr server: undefined field deleted" I was getting earlier. Totally baffled me because the field "deleted" was in my schema.xml but NOT in my managed-schema.
Moving on.
I can now run a search and end up with no error messages (in MODX or solr.log) but get zero results. The generated query looks like this:
webapp=/solr path=/select params={q=parks&indent=on&start=0&fq=published:1&fq=searchable:1&fq=deleted:0&rows=10&version=2.2&wt=xml} hits=0 status=0 QTime=1
Trying to simplify even more, I wanted to get rid of the "fq" values (filter query). So I commented out the entire following section (again from simplesearchdriversolr.class.php):
/* handle hidemenu option */
/*
$hideMenu = $this->modx->getOption('hideMenu',$scriptProperties,2);
if ($hideMenu != 2) {
$query->addFilterQuery('hidemenu:'.($hideMenu ? 1 : 0));
}
*/
/* handle contexts */
/*
$contexts = $this->modx->getOption('contexts',$scriptProperties,'');
$contexts = !empty($contexts) ? $contexts : $this->modx->context->get('key');
$contexts = implode(' ',explode(',',$contexts));
$query->addFilterQuery('context_key:('.$contexts.')');
*/
/* handle restrict search to these IDs */
/*
$ids = $this->modx->getOption('ids',$scriptProperties,'');
if (!empty($ids)) {
$idType = $this->modx->getOption('idType',$this->config,'parents');
$depth = $this->modx->getOption('depth',$this->config,10);
$ids = $this->processIds($ids,$idType,$depth);
$query->addFilterQuery('id:('.implode(' ',$ids).')');
}
*/
/* handle exclude IDs from search */
/*
$exclude = $this->modx->getOption('exclude',$scriptProperties,'');
if (!empty($exclude)) {
$exclude = $this->cleanIds($exclude);
$exclude = implode(' ',explode(',', $exclude));
$query->addFilterQuery('-id:('.$exclude.')');
}
*/
/* basic always-on conditions */
/*
$query->addFilterQuery('published:1');
$query->addFilterQuery('searchable:1');
$query->addFilterQuery('deleted:0');
*/
Now I'm getting an error in my browser stating:
Fatal error: Call to a member function checkPolicy() on a non-object in /home/townofco/core/components/simplesearch/model/simplesearch/driver/simplesearchdriversolr.class.php on line 220
and a MODX error log of:
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 595) PHP warning: strrpos() expects parameter 1 to be string, array given
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 600) PHP warning: strrpos() expects parameter 1 to be string, array given
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 606) PHP warning: strtolower() expects parameter 1 to be string, array given
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 617) PHP warning: Illegal offset type in isset or empty
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 618) PHP warning: class_exists() expects parameter 1 to be string, array given
[2016-06-18 02:49:10] (ERROR @ /home/townofco/core/xpdo/xpdo.class.php : 643) Could not load class: Array from mysql..
BUT I'm getting hits in Solr finally (from solr.log):
webapp=/solr path=/select params={q=parks&indent=on&start=0&rows=10&version=2.2&wt=xml} hits=30 status=0 QTime=0
I know nothing about PHP so I'm back to being at a total loss. However, I still feel that this is a step in the right direction. Is anyone able to get the missing puzzle piece?!
Edit: I commented out the little chunk in simplesearchdriversolr.class.php that was giving me the error message:
/** @var modResource $resource */
/* $resource = $this->modx->newObject($d['class_key']);
if ($resource->checkPolicy('list')) {
$response['results'][] = $d;
} */
and I don't get any error messages in MODX. A search results page still shows zero results. However, in my solr.log I am still getting hits:
webapp=/solr path=/select params={q=parks&indent=on&start=0&rows=10&version=2.2&wt=xml} hits=30 status=0 QTime=0
Am I correct in thinking that piece that I commented out is what generates the results array? If so, how can I put it back in without the previous error messages?
[ed. note: matthewmeredith last edited this post 7 years, 10 months ago.]