Closed (works as designed)
Project:
Apache Solr Search
Version:
7.x-1.0-rc5
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2012 at 10:34 UTC
Updated:
12 Oct 2012 at 10:19 UTC
Jump to comment: Most recent file
Comments
Comment #1
nick_vhYou should write a status callback and implement
function hook_apachesolr_entity_info_alter(&$entity_info) {If you have a good example, please post it here so others can use this as a guidance
Comment #2
johnennew commentedHi Nick_vh,
So I think I will actually replace the apachesolr default status callback with this method.
I wonder if a hook in the apachesolr_index_node_status_callback function might be more elegant or a more general hook_apachesolr_entity_exclude() at a higher level?
Comment #3
nick_vhThis code is 5 lines and you are looking for a more elegant solution? :-)
Comment #4
johnennew commentedOK, maybe not more elegant! But the previous method was much more straight forward for system integrators. This method requires a more detailed knowledge of the inner workings of the apachesolr module. This could be fixed with some more comments in the API file though, please find suggestion attached.
Comment #5
johnennew commentedSorry, got the name of the hook wrong in the documentation. Here is an updated patch.
Comment #6
nick_vhI'm all up for improvements in documentation ;-) Will commit something in this line to the api docs
Comment #7
sawtell commentedI found I had to include the apachesolr.index.inc file before calling apachesolr_index_node_status_callback() otherwise it caused fatal errors when publishing/unpublishing content.
Comment #8
nick_vhCommitted, thanks!
Comment #9
rbishop commentedthank you for this example, im having trouble getting the hook_apachesolr_entity_info_alter to fire. im on BETA16 and added #2 to my custom module
ive tried
drush solr-delete-index, drush solr-mark-all, drush solr-index
and tried to update my content and publish.
in my callback im just checking for nid == x to remove single nodes buy nid but dont see any changes to my results.
Comment #10
lazysoundsystem commentedI'm also having trouble with this with BETA16.
I can get the hook_apachesolr_entity_info_alter() to fire (twice) by clearing the cache, but not on indexing content - so my custom node_status_callback isn't getting picked up either.
I'll report back when I find out what's going on...
Comment #11
nick_vhComment #12
sawtell commentedIf you are marking all content to reindex, the process doesn't use the status callback.
The reindex callback is used which basically selects all bundles to be indexed straight from the node table.
See the default function in apachsolr.index.inc:
This means if you have something specific in your status callback such as excluding pages that are tagged with a certain term (e.g. no_index), the reindex function won't take that into account and will simply mark all content to index, regardless of whether or not that content is tagged with "no_index".
I had to alter the select query to index only the content I wanted indexed.
Comment #13
nick_vhThat sounds like a bug indeed, we might need to loop over all content to make sure we use this exclude function.
Comment #14
nick_vhduplicate of #1509790: Status is not checked when a reindex is initiated
Comment #15
duellj commentedSince this issue is linked to in apachesolr.api.php, it'd be helpful to note the correct way to add a status callback, since 'status callback' is now an array (to allow multiple status callbacks, which is great). Updated example from #2:
Comment #16
nick_vhThanks!
Comment #17
osopolarThis issue is not a duplicate, because its about "What is the correct alternative approach to the hook_apachesolr_node_exclude".
And I am wondering, because hook_apachesolr_node_exclude() is still there. So I guess we don't need an alternative anymore. See also #904428: Document how to remove excluded nodes from index.
Setting this to "needs review" in case I am overlooking something.
Comment #18
nick_vhThere is no alternative :) The hook is back in the module