I've recently upgraded to the 6.x-1.0 version from one of the beta versions and am now seeing an issue with the searches not including the node titles when searching? I'm not sure what I am missing?

The nodes being searched are CCK types. Finds on fields in the type are working, but the node title doesn't, e.g. http://moteltrip.com/search/apachesolr_search/Kasha yields no results where as http://moteltrip.com/search/apachesolr_search/14556 yields a node with Kasha in the title.

I have tried re-indexing several times. If I view the index files, I see that the titles are included. I'm implementing two hooks: apachesolr_cck_field_mappings and apachesolr_process_results. I tried re-indexing without these hooks implemented, but still saw the same issue. Here is the code for that that I have taken from the examples I found online and tweaked.

function mymodule_apachesolr_cck_field_mappings() {
  $mappings = array();
  $mappings['text'] = array(
    'callback' => 'example_callback',
    'index_type' => 'string',
    'widget_types' => array(
      'text_textfield' => TRUE,
      'text_textarea' => FALSE,
      'optionwidgets_select' => TRUE,
    ),
  );
  return $mappings;
}

function example_callback($node, $fieldname) {
  $fields = array();
  foreach ($node->$fieldname as $field) {
    if ($fieldname == 'field_state' || $fieldname =='field_city') {
      $fields[] = array('safe' => $field['safe']);
    }
  }
  return $fields;
}

Any thoughts? Where do I go next for troubleshooting?

Comments

jpmckinney’s picture

Is "Kasha's Pleasant Hill Motel" the node's title or is it the value of a CCK field?

ahansen1’s picture

It's the node title. The other thing I forgot to mention is that I found the weightings and have left everything as the defaults. So, the title is weighted 13 in the admin/settings/apachesolr/query-fields page.

ahansen1’s picture

Anyone have any thoughts? I would happily pay a bounty for anyone that is able to help.

jpmckinney’s picture

What happens if you delete the index, and then re-index? (with and without those callbacks)

ahansen1’s picture

Same result. I've removed the callbacks and deleted the index. It's re-indexing now. But, a new example of the documents index demonstrates the issue:

http://moteltrip.com/search/apachesolr_search/Greenport (a city)
http://moteltrip.com/search/apachesolr_search/Drossos (title of a node in that city)

jpmckinney’s picture

Trouble is I can't reproduce the error. What modules do you have installed?

Scott Reynolds’s picture

The error seems like its in the query that is sent over to the solr server. Probably the title isn't in the qf.

Or it could be in the config.xml. Might be defaulting to the standard query template instead of the dismax. So, is there any difference between your solrconfig.xml and the modules solrconfig.xml. Is there any difference between your schema.xml and the module's schema.xml? Please run the diff command to be sure.

You can also put a drupal_set_message in apachesolr/SolrPhpClient/Apache/Solr/Service.php right below this line near the bottom of the class

// because http_build_query treats arrays differently than we want to, correct the query
		// string by changing foo[#]=bar (# being an actual number) parameter strings to just
		// multiple foo=bar strings. This regex should always work since '=' will be urlencoded
		// anywhere else the regex isn't expecting it
		$queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);

So make that this

// because http_build_query treats arrays differently than we want to, correct the query
		// string by changing foo[#]=bar (# being an actual number) parameter strings to just
		// multiple foo=bar strings. This regex should always work since '=' will be urlencoded
		// anywhere else the regex isn't expecting it
		$queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
		drupal_set_message(urldecode($queryString));

And that will print out the query string that is being sent to the server. In there, title should be part of the fl and the qf. Please paste the query here so someone can look at it and try to help you.

ahansen1’s picture

Thanks Scott. I'm just plain stupid. It was the solrconfig.xml

ahansen1’s picture

Status: Active » Closed (fixed)