So I have Sarnia up and working. I have it in a pretty basic Drupal test site. It's hitting a Solr Index created on another Drupal site using ApacheSolr module.

Everything works, except I get a ton of Warnings "Warning: preg_match() expects parameter 2 to be string, array given in SearchApiSolrService->extractResults() (line 1305 of /var/www/drupalvm/drupal/sites/all/modules/search_api_solr/includes/service.inc)."

If I add a test for an array (3rd line) to the offending code, the warning goes away.

if (isset($field_options[$search_api_property]['type'])
&& $field_options[$search_api_property]['type'] == 'date'
&& !is_array($result['fields'][$search_api_property])
&& preg_match('/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/', $result['fields'][$search_api_property])) {
$result['fields'][$search_api_property] = strtotime($result['fields'][$search_api_property]);
}

Thoughts?

Comments

cdesautels created an issue. See original summary.

jmdeleon’s picture

Component: Code » Miscellaneous
Category: Bug report » Support request
Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

Not entirely sure that this is an issue with Sarnia (hence I am changing this to a Support Request): Your warning message refers to the general Search API Solr module.

It also sounds like you are trying to read the Solr index of another Drupal site with Sarnia, attempting to read the data in the Solr index of the other site as Views with Sarnia. There are easier ways to access the Drupal data of one site from another (Feeds, Migration, Services).

cdesautels’s picture

I'm hitting a solr index that was generated from another Drupal site using ApacheSolr module (as your documentation suggested), but don't get hung up on the source of the data. This is just a test case. The ultimate goal is to hit an index generated from a web crawler like Nutch from a wide assortment of non-drupal sites. I thought the point of Sarnia was to be able to pull in any Solr data and have it provided to Views as an entity. This is working except for this error message. Which is being caused by an $result['fields'][$search_api_property] as an array is being passed to preg_match.

So there has to be a way to keep this from happening or a test for the array should be included.

jmdeleon’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

This looks like an issue in Search API Solr, specifically processing date fields in an index. You may want to bring the issue up there.

The additional test you added causes Search API Solr to punt on attempting a preg_match after a field has been determined by Search API Solr as a Date Field. I attempted a test creating a Sarnia index over a Search API Solr-generated Drupal content index and did not get this warning. Without knowing more about the Solr index you are using, you may want to check your ApacheSolr generated source index.

As you noted above, building a Sarnia index over an existing Drupal content index is not a practical use of the Sarnia module, so I am closing this issue.

cmseasy’s picture