Hi there,
I'm using search_api_solr 1.2 and search_api 1.8.
I have defined a view on my node index that tries to output the "Item language" field (ss_search_api_language).

The result always came out empty, except when enabling the "Retrieve result data from Solr" checkbox on the Solr server config page.
So I had to implement the following hook:

function hook_search_api_solr_query_alter(array &$call_args, SearchApiQueryInterface $query) {
  $call_args['params']['fl'] .= ',ss_search_api_language';
}

Is this a bug or a correct behavior? If so, can it be documented?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: Using "Item language" in views with search_api_solr: bug or expected behavior? » Remove Views field handlers for "virtual" fields
Project: Search API Solr » Search API
Version: 7.x-1.2 » 7.x-1.x-dev
Component: Documentation » Views integration
Status: Active » Needs review

It is expected behavior, but probably not really correct. The problem is that we currently add Views field handlers for fields which are added by data alterations (and the "Item language" field, which is added in a similar way) and don't really have any values. Since those won't show any values, except with such workarounds, they probably shouldn't be included at all.

The attached patch should remove them, please test!
For displaying the language, just use the normal language field instead.

drunken monkey’s picture

grota’s picture

Status: Needs review » Reviewed & tested by the community

Yep, it works

drunken monkey’s picture

I already wanted to commit this, but mollux mentioned a great use case for actually leaving this. But since it's Solr-specific, we should probably just support it for Solr: see #2099683: Add support for "virtual fields" in Views.
I'm waiting with this one until that other patch is (ready to be) committed.

drunken monkey’s picture

Category: support » task
Status: Reviewed & tested by the community » Fixed

OK, #2099683: Add support for "virtual fields" in Views is in – so there's nothing in the way of fixing this.
Committed. Thanks for testing!

Status: Fixed » Closed (fixed)

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