Closed (duplicate)
Project:
Apache Solr Search
Version:
7.x-1.0-beta16
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
6 Feb 2012 at 21:15 UTC
Updated:
13 Sep 2012 at 05:58 UTC
Hello.
I've created field 'Include to the search index' for node type 'publication'. It means that I want to exclude some nodes from index. I explored apachesolr code a little bit and found hook_apachesolr_entity_info_alter(). Implementing it I try to change status callback where I can check a value of my field. This is code below.
function inti_apachesolr_entity_info_alter(&$entity_info) {
$entity_info['node']['status callback'] = 'inti_index_node_status_callback';
}
function inti_index_node_status_callback($node, $type) {
if ($type == 'publication') {
$status = (!empty($node->field_do_search)) ? ($node->status && $node->field_do_search['und'][0]['value']) : $node->status;
} else {
$status = $node->status;
}
return $status;
}
But when I reindex my content, I still can see all publications.
As I could understand while "debugging", inti_index_node_status_callback() is never called, but I don't know why. Am I doing something wrong?
Comments
Comment #1
nick_vhCan you verify this callback is being called?
apachesolr_index_node_status_callback?
I'm thinking we might have a mistake and that this callback probably should be called in apachesolr_entity_should_index.
Afaik these functions are currently only called whenever a entity is updated or inserted, perhaps you are trying to reindex all at once?
Comment #2
Georgique commentedSome your code:
What I see: firstly, I think that hook should be named hook_apache_solr_entity_info, also it should be added altering hook hook_apachesolr_entity_info_alter. In function apachesolr_entity_info_alter we can see info about HOOK_apachesolr_entity_info in comments but I didn't found it in code.
Secondly, as you can see, I added a call of wtf() function to callback apachesolr_index_node_status_callback; this functions writes content of its argument to file. After reindexing all content file was empty, so I think that callback had never been calling. Thirdly, I noted that implementations of hook_apachesolr_entity_info_alter are calling only when I clearing the cache. Is it write?
Comment #3
Georgique commentedSorry for up, but are there any news?
Comment #4
nick_vhMarking as duplicate of #1442358: General Mock object for simpletests (expected value/real value object model)
Comment #5
sawtell commentedHope this isn't off topic
I have the same issue that the status callback only takes effect when the node is updated.
What is the method to use if I want the reindex process to acknowledge the status callback?
Comment #6
seemas commentedI also was looking how to exclude some nodes from index.
Here is the module for that: https://drupal.org/project/apachesolr_exclude_node
7.dev just launched.