-
Notifications
You must be signed in to change notification settings - Fork 10
Description
What is this?
Now that we have OCR we want to avoid confusing users and leading them to think they can "search" if no Solr Document with OCR exists.
How to do this?
- Find out if a certain ADO (Node bearing a strawberryfield) had already
strawberryfield_flavor_datasourcesearch api sources documents generated and those can be found.
- Look at this code:
- https://github.com/esmero/strawberry_runners/blob/main/src/Plugin/QueueWorker/AbstractPostProcessorQueueWorker.php#L530
This method can be copied/simplified and abstracted/generalized to be able to check (true/false) if any ADO has a particular post processor generated Search API index entry. The way I see this is, abstracting/copying this method to be check for "any" instead of a specific one Search API ID that matches the critters and be used in a service either in thisformat_strawberryfieldmodule or in any of the utility Service that exists in our corestrawberryfieldmodule (e.g https://github.com/esmero/strawberryfield/blob/1.0.0-RC1/src/StrawberryfieldUtilityService.php)
In other words. The function should have as arguments: the NODE ID, and the PostProcessor Plugin ID we want (in this caseocr)
which Search API fields to target can be seen in the Search API/ SOLR Fields tab for the Strawberryfield flavor datasource via the UI, but also, this is how one of those Solr docs look like (I removed allsort_*fields here to make it more compact)
{
"id":"5qc1nk-default_solr_index-strawberryfield_flavor_datasource/4:1:en:6ba944b8-8518-415e-abd2-4af808a457c7:ocr",
"sm_context_tags":["search_api_X2f_index_X3a_default_solr_index",
"search_api_solr_X2f_site_hash_X3a_5qc1nk",
"drupal_X2f_langcode_X3a_und"],
"tm_X3b_und_fulltext_with_original_ocr":["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<ocr><p xml:id=\"sequence_1\" wh=\"2550 3300\"><b><l><w x=\".118 .095 .085 .014\">Sheppard</w><w x=\".209 .095 .052 .011\">Helen</w><w x=\".267 .095 .104 .01\">...."],
"ss_search_api_language":"und",
"ss_title_2":"Helen Sheppard Oral History Interview (Excerpt)",
"sort_X3b_en_processor_id":"F.L\u0000",
"timestamp":"2021-01-13T17:14:44Z",
"site":"http://localhost:8001/",
"ss_parent_id":"4",
"ss_sequence_id":"1",
"boost_document":1.0,
"ss_search_api_id":"strawberryfield_flavor_datasource/4:1:en:6ba944b8-8518-415e-abd2-4af808a457c7:ocr",
"ss_processor_id":"ocr",
"its_uid_2":0,
"_version_":1688792554279010304,
"ss_checksum":"2feffd1c3f381a542db82931982dd834",
"ss_search_api_datasource":"strawberryfield_flavor_datasource"
}-
Call this new
methodfrom here https://github.com/esmero/format_strawberryfield/blob/1.0.0-RC1/src/Plugin/Field/FieldFormatter/StrawberryPagedFormatter.php#L322
If result== FALSEadd a Drupal Setting entry/flag that allows us..(continued..) -
... In the JS to disable the search box https://github.com/esmero/format_strawberryfield/blob/1.0.0-RC1/js/iiif-iabookreader_strawberry.js#L37, somewhere there. There are IABOOK reader specific arguments that can be used to disable functionality (that should all the code that is needed on the JS)
-
Make sure we have the right caching context so the FALSE does not get cached forever and the next time a user comes back and the documents are already there the search box is showed
@pcambra this one is for you! Feel free to ask/comment and reach out to me any time.