When enabling the 'Content access' Processor for a given search API index, the new 'status' field is created as a boolean type.
The users status field is stored in as a integer within Drupal 8, therefore when attempting to index data on the search api server it errors (see screenshots).

Watchdog error from search_api module:

Drupal\search_api\SearchApiException while trying to index items on index Dev Elasticsearch content index: An error occurred during indexing. Check your watchdog for more information. in Drupal\elasticsearch_connector\Plugin\search_api\backend\SearchApiElasticsearchBackend->indexItems() (line 496 of /modules/contrib/elasticsearch_connector/src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php)

Watchdog error from elasticsearch_connector module:

failed to parse field [status] of type [boolean]. Failed to parse value [1] as only [true] or [false] are allowed. for id: 

Comments

robertbourne created an issue. See original summary.

robertbourne86@gmail.com’s picture

Patch attached (search_api-content_access_processor-3055151-1-8.6.12.patch)

robertbourne86@gmail.com’s picture

Issue summary: View changes
robertbourne86@gmail.com’s picture

StatusFileSize
new1.87 KB

Changed patch to update functional tests

robertbourne86@gmail.com’s picture

Updated integration test for when adding fields to content index

robertbourne86@gmail.com’s picture

robertbourne86@gmail.com’s picture

Status: Active » Needs review
borisson_’s picture

Issue tags: -search_api

I'm not sure about this one. It's not because the user module is doing it wrong that we should copy that behavior. I'm very curious to see @drunken monkey's opinion on this one.

drunken monkey’s picture

Assigned: robertbourne86@gmail.com » Unassigned
Priority: Major » Normal

Thanks for reporting this problem! However, the fix is in the completely wrong place. The value is 0 or 1, so “Boolean” just makes a lot more sense than “Integer”.
Either the Elasticsearch Connector backend should be more tolerant there, and cast values appropriately – or, indeed, our data type plugins should do their job and take of it themselves. What are they (and their getValue() methods) for, if not to prepare the value according to the data type? (Really not sure why we never implemented that so far.)
So, I’m proposing the attached patch to resolve this – please test to see whether it solves your problem! (Reviews also welcome, of course.)

drunken monkey’s picture

Ahem. *cough* The attached patch!

Status: Needs review » Needs work
drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB
new3.22 KB

Aaah, $haystack, $needle doesn’t make any sense!!1 </rant>

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, this looks good.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks for reviewing!
Committed.

  • drunken monkey committed f1160ef on 8.x-1.x
    Issue #3055151 by drunken monkey, borisson_: Content Access Index...

Status: Fixed » Closed (fixed)

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