Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When deleting a node, it is not being removed from the Solr index. I am using Solr4 along with the latest dev module (ported to 6.x-3.x) and do not currently use Solr3 to test against. Deleting a node calls apachesolr_remove_entity, which ends up using deleteByQuery.
If I use deleteById, the entity is removed. If I change the query method in deleteByQuery to use the following it also works:
$rawPost = '<delete>';
$rawPost.= '<id>'. htmlspecialchars($document_id, ENT_NOQUOTES, 'UTF-8') . '</id>';
$rawPost.= '<query>' . htmlspecialchars("sm_parent_document_id:$document_id", ENT_NOQUOTES, 'UTF-8') . '</query>';
$rawPost.= '</delete>';
In what case would sm_parent_document_id even exist and is this necessary to have? I'm happy to create a patch (or updated the existing solr4 path) with a fix depending on which method is preferred.
Comment | File | Size | Author |
---|---|---|---|
#20 | 1874420-20.patch | 8.15 KB | Nick_vh |
#18 | 1874420-18.patch | 8.21 KB | Nick_vh |
#16 | 1874420-16.patch | 8.28 KB | Nick_vh |
#12 | 1874420-11.patch | 6.23 KB | Nick_vh |
#9 | 1874420-9.patch | 6.15 KB | Nick_vh |
Comments
Comment #1
j0rd CreditAttribution: j0rd commentedI'm noticing the same problem. None of my nodes are getting removed.
Comment #2
j0rd CreditAttribution: j0rd commentedChanging priority to major. Pretty big bug.
Comment #3
j0rd CreditAttribution: j0rd commentedHere's a hack patch to resolve the issue.
If you need to fix your install, you might want to look at my module to prune non-existant nodes from a solr index (with out having to delete the whole thing).
#885484: "Delete Orphaned Nodes from Index" - a batch API for large sites
Comment #4
Nick_vhI'll look at this as soon as possible, Might need to add some tests so we can actually figure this out. Too bad the testbot does not have a solr running ;-)
Comment #5
kriboogh CreditAttribution: kriboogh commentedWe are running this one against a solr4 server and can confirm that the patch in #3 works for deleting nodes.
Comment #6
Nick_vhIs this only a problem with solr 4?
Comment #7
Nick_vhIs this only a problem with solr 4?
Comment #8
Nick_vhSolving this another way until we've figured it out. Omitting the delete by query is not an option afaik.
Committed the following patch and will do a follow-up asap
Comment #9
Nick_vhComment #10
Nick_vhThis patch actually solves multiple Solr 4 problems that we currently encounter. For some reason it is way stricter when sending documents so we should figure that out.
Comment #12
Nick_vhOeps, my bad
Comment #14
Nick_vh#12: 1874420-11.patch queued for re-testing.
Comment #16
Nick_vhDummySolr did not have the getSolrVersion method
Comment #18
Nick_vhlate night coding makes up for a whole lot of errors, and my simpletest is broken so relying on drupal.org...
Comment #19
Nick_vhLooking for a more root cause to this problem
https://issues.apache.org/jira/browse/SOLR-3432
Comment #20
Nick_vhOk, so it seems that the id slashes trigger a regular expression in Solr 4.0 and that is why the query did not work. This patch should solve it without working around it.
Comment #21
Nick_vhCommitted to 7.x-1.x.
Comment #22
charos CreditAttribution: charos commentedIs the patch backported to latest 6.x-3.x-dev(Straight backport of the 7.x-1.x branch) as well ?
Comment #23
AntiNSA CreditAttribution: AntiNSA commentedwaiting for 6.3 support
Comment #24
AntiNSA CreditAttribution: AntiNSA commentedComment #25
Nick_vhseems this slipped in the patch. Some explanation here : If the index_key is single and the field is single, there is no point in having multiple values in the field causing solr to break. It slipped in this patch so it's worth to mention what was done here.
Comment #26
David_Rothstein CreditAttribution: David_Rothstein commentedThe code that slipped in actually caused big problems: #1984664: Single-valued taxonomy field facets disappear after upgrading from 7.x-1.1
That's because the $ancestors variable doesn't just contain the term's parents; it contains the term itself also. So single-valued taxonomy fields are no longer being indexed.
I have a patch to fix it in the above issue.
Comment #27
David_Rothstein CreditAttribution: David_Rothstein commentedActually, even beyond that problem, the
$field_info['multiple'] == true
check doesn't really make sense to me here for other reasons; see my comment at #1984664-12: Single-valued taxonomy field facets disappear after upgrading from 7.x-1.1 for why.