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
Comment #2
robertbourne86@gmail.com commentedPatch attached (search_api-content_access_processor-3055151-1-8.6.12.patch)
Comment #3
robertbourne86@gmail.com commentedComment #4
robertbourne86@gmail.com commentedChanged patch to update functional tests
Comment #5
robertbourne86@gmail.com commentedUpdated integration test for when adding fields to content index
Comment #6
robertbourne86@gmail.com commentedComment #7
robertbourne86@gmail.com commentedComment #8
borisson_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.
Comment #9
drunken monkeyThanks 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.)
Comment #10
drunken monkeyAhem. *cough* The attached patch!
Comment #12
drunken monkeyAaah,
$haystack, $needledoesn’t make any sense!!1 </rant>Comment #13
borisson_Yeah, this looks good.
Comment #14
drunken monkeyAwesome, thanks for reviewing!
Committed.