An uncaught exception is thrown when a field is not indexed, this causes a fatal error.

search_api/includes/query.inc
Line 552

<?php
  public function fields(array $fields) {
    $fulltext_fields = $this->index->getFulltextFields();
    foreach (array_diff($fields, $fulltext_fields) as $field) {
      throw new SearchApiException(t('Trying to search on field @field which is no indexed fulltext field.', array('@field' => $field)));
    }
    $this->fields = $fields;
    return $this;
  }
?>

The issue appears to be in search_api/contrib/search_api/includes/query.inc
Line 576

<?php
  public function fields(array $fields) {
    if (!$this->errors) {
      $this->query->fields($fields);
    }
    return $this;
  }
?>

Comments

ianwesty’s picture

Issue tags: +search_api
ianwesty’s picture

ianwesty’s picture

Status: Active » Needs review
ianwesty’s picture

Assigned: ianwesty » Unassigned
drunken monkey’s picture

Component: Framework » Views integration
Issue tags: -search_api, -SearchApiException
StatusFileSize
new3.02 KB

Ah, you're right, thanks – these should definitely be caught.
However, I think the search should then be aborted, not just an error logged. After all, the results might be completely different.
Similar erorrs are in the fulltext argument and the sort handler. Patch attached.

PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.

ianwesty’s picture

Yeah fair shout about the search being aborted.

Thanks for the heads-up about the issue tags.

drunken monkey’s picture

Status: Needs review » Fixed

OK, then I guess this works for you?
So, committed.
Thanks again!

ianwesty’s picture

No problem - thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

arnoldbird’s picture

Status: Closed (fixed) » Active

I posted a separate report for this (https://www.drupal.org/node/2576265), thinking it was not the same issue. But I think it's probably the same bug and I'm still seeing it in the latest dev snapshot.

I can make the errors go away by checking the Index box for the two fields search api otherwise complains about. I don't know why the module seems to insist that I index these two fields -- one is actually a property of a custom entity, and the other is a field attached to the entity.

drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

In your view's "Search: Fulltext search" filter, do you maybe have non-existent fields configured as the search fields?
To check, just open the filter's settings, re-save them as-is and then save the view.

legolasbo’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.