I think the query in apachesolr_get_nodes_to_index() should be db_rewrite_sql wrapped; some modules use db_rewrite hooks to add visibility access to nodes.

CommentFileSizeAuthor
#7 db_rewrite.patch1.77 KBflexer
#6 dbrewrite.patch1.75 KBflexer

Comments

flexer’s picture

Should db_rewrite_sql also the queries in apachesolr_index_status()

I did it and it seems to work fine.

flexer’s picture

Mmmh... also in the hook_enable of apachesolr.install. Btw, shouldn't be hook_disable() to implement too? Like, to empty the apachesolr_search_node. Or it'll trigger the full reindex?

flexer’s picture

Another one: the "select count(*)" in apachesolr_search_search

pwolanin’s picture

The way things are set up now, the search only respects node access grants, not other uses of db_rewrite_sql (e.g. my modr8 module). If we did this re-write, would it be on the basis of an anonymous user? An authenticated user? I really don't see that this is feasible in practice. We need to be able to do the access check at query time.

pwolanin’s picture

I think the bottom line is that to moderate content with Solr you need to have the moderated content be unpublished

flexer’s picture

Status: Active » Needs review
StatusFileSize
new1.75 KB

I see your point. The problem is that we have many sites with one big shared node table. We do not use node_access to route content visibility (because the setup is greatly complex), but instead we use our system (similar, just another table - something like the domain module). Long story short: we rely all over on db_rewrite_sql to let A SITE (and its users) see only ITS nodes (users are also shared, but this is another story).

If you do not add the db_rewrites, no problem... we still continue to patch the modules ourselves :)

Attached is the patch we use.

Thank you

flexer’s picture

StatusFileSize
new1.77 KB

Sorry, that patch is all wrong.

Better one, this time :)

pwolanin’s picture

There is probably much easier way to do this - if you want to restrict results to just the current site, modify the query (with the hook) to add a fq param to match the site hash.

flexer’s picture

Yes, I have that too (and it works).
The rewrite are needed when the module looks for available nodes to index.


if (module_exists('apachesolr')) {
  /* Modify the delete index Solr query to add the site hash */
  function rrsearch_apachesolr_delete_index_alter(&$query) {
    if ('*:*' == $query)
      $query = 'hash:' . apachesolr_site_hash();
    else
      $query .= ' hash:' . apachesolr_site_hash();
  }
  
  function rrsearch_apachesolr_modify_query(&$query, &$params) {
    $query->add_field("hash", apachesolr_site_hash());
  }
  
  function rrsearch_menu_alter(&$callbacks) {
    $callbacks['search/node/%menu_tail']['access callback'] = FALSE;
    # Apache solr search tab label is not configurable, so we hijack the callback
    $callbacks['search/apachesolr_search/%menu_tail']['title callback'] = 'rrsearch_apachesolr_name';
  }
  
  function rrsearch_apachesolr_name() {
    return t('Content');
  }
}






pwolanin’s picture

Status: Needs review » Closed (works as designed)

This last snippet is totally wrong (At least now w/ the dismax handler). You must add it as a fq param.