- Issue created by @plinkowski
- πΊπΈUnited States agentrickard Georgia (US)
@plinkowski I think this is properly handled on the Domain side using Domain Source, which allows you to force a canonical URL for any node assigned to multiple domains.
I suspect that without using that module, the search index will be based on the domain from which the indexing runs.
- πΊπΈUnited States agentrickard Georgia (US)
Technical notes -- taken from this module's README:
"sm_site_name":["Drupal 8"], "sm_urls":["http://d8.fs-demo.local/node/10"],
- The annotation "sm_" means "string multiple" (an array of strings)
- The React application simply iterates over those arrays when printing links to the node
- πΊπΈUnited States agentrickard Georgia (US)
Technical note 2:
It is possible that the getSiteName() Helper is not working properly since the DOMAIN_ACCESS_FIELD constant now lives in an interface. See this code:
// @TODO: Handle domain access properly. if (defined('DOMAIN_ACCESS_FIELD')) { $manager = \Drupal::service('domain.negotiator'); $active_domain = $manager->getActiveDomain(); $site_name = $active_domain->label(); }
See lines 167-172 of src/Utility/Helpers.php
- πΊπΈUnited States agentrickard Georgia (US)
I see, Joe provided more clarity.
The SiteName and URL fields (in Solr) are both positional arrays. We need to ensure that they are sorted in the same way prior to indexing.
It may be that DomainAccessManager::getContentUrls needs to use $domains = $this->domainStorage->loadMultipleSorted($list); instead of $domains = $this->domainStorage->loadMultiple($list);
See line 187 of domain_access/src/DomainAccessManager.php
Worst case, those fields should be sorted / reconciled in hook_search_api_solr_documents_alter() inside Domain Access.
- πΊπΈUnited States agentrickard Georgia (US)
Moving to Search API Field Map, which is responsible for getting the Site Name and URL values.
- Status changed to Postponed: needs info
over 1 year ago 6:26pm 22 August 2023 - πΊπΈUnited States agentrickard Georgia (US)
Paul-
I have not been able to reproduce this locally running Drupal 10. Here's what my index shows:
"sm_urls":[ "http://example.local/node/10", "http://four.example.local/node/10", "http://one.example.local/node/10", "http://two.example.local/node/10" ], "sm_site_name":[ "Domain 10", (this is the default domain) "Four", "One", "Two" ],
This matches exactly what we expect.
Some questions:
* What Drupal and module versions are you running?
* What is in "$config['search_api_federated_solr.search_app.settings']['facet']['site_name']['site_list'] " in settings.php?
* Do the site name filters work as expected?
* Do you have admin access to the SOLR index so we can see the raw data (like shown above)? - Status changed to Active
over 1 year ago 8:43pm 22 August 2023 - πΊπΈUnited States agentrickard Georgia (US)
We managed to track this down.
Apparently, SOLR auto-sorts multivalue text fields (see https://solr.apache.org/guide/7_2/docvalues.html) for instance. In this case, since the names of the sites and the urls don't match (in alphabetical order), the sort is thrown off.
Here's how we broke that on local testing:
27 "sm_urls":["http://example.local/node/1", "http://four.example.local/node/1", "http://one.example.local/node/1", "http://three.example.local/node/1", "http://two.example.local/node/1"], "sm_site_name":["Domain 10", "Four", "One", "Two", "XThree"],
Note that both arrays are alpha-sorted. The "XThree" throws that off.
There might be ways to force that behavior to change at the index level, but that would involve handling schema files, which could be problematic.
It may be better to have a handler to normalize this data after it is retrieved. We would load the sort in a subscriber to
\Drupal\search_api_solr\Event\PostExtractResultsEvent
Which is earlier versions is hook_search_api_solr_search_results_alter()
- πΊπΈUnited States agentrickard Georgia (US)
The correct solution would seem to be:
- When using Domain Access, change the Site Name and URLs fields to Storage Only in the Search API field configuration
- Write an implementation of the \Drupal\search_api_solr\Event\PostExtractResultsEvent handler in Search API Field Map (which is where we handle all domain-specific handling.
- In that implementation, copy any z*_ field for a document to s*_ so that it can be used by the React app.
- πΊπΈUnited States agentrickard Georgia (US)
We have a fix for this inside the main module. Re-filing.
- Status changed to Needs review
over 1 year ago 1:36pm 25 August 2023 - πΊπΈUnited States agentrickard Georgia (US)
Last patch has bad logic.
- πΊπΈUnited States ddavisboxleitner
I have tested the patch and it works as intended. In testing, the site names and urls are in correct order.
sm_urls array ( 0 => '//example.local', 1 => '//one.example.local', 2 => '//two.example.local', 3 => '//four.example.local', ) sm_site_name array ( 0 => 'Domain 10', 1 => 'One', 2 => 'Two', 3 => 'Four', )
- πΊπΈUnited States agentrickard Georgia (US)
Original patch was malformed and returned links to the site homepages, not the content.
-
agentrickard β
committed c66977e7 on 4.x
Issue #3381993 by agentrickard, plinkowski, ddavisboxleitner: Domain...
-
agentrickard β
committed c66977e7 on 4.x
Automatically closed - issue fixed for 2 weeks with no activity.