After I delete the Solr index and I re-index, the taxonomy-based enabled filters (facets) no longer display. Why?

Drupal 6.16
Apache Solr search 6.x-2.0-beta2

Comments

jpmckinney’s picture

Category: bug » support
Priority: Critical » Normal
jpdaut’s picture

For example, Taxonomy vocabulary: Filter by taxonomy Catalog (my Ubercart Catalog) is gone. Other taxonomies also no longer show. If I create new Taxonomies and enable them as Facets, then they show.

Need to be able to delete the solr index and rebuild the index table at any time w/o running the risk of these problems.

Not sure if this has anything to do with it, but, is http://drupal.org/node/509526 really fixed? Afer deleting the index, I noticed in phpmyAdmin that my {apachesolr_search_node} table was still populated. I thought it should be empty as long as I have not re-indexed yet?

If anyone could shed light on this it would be really appreciated.

jpmckinney’s picture

I don't think apachesolr_search_node needs to be deleted for re-indexing to work.

Are you saying that those taxonomy filters no longer show up at admin/settings/search/apachesolr/enabled-filters?

jpdaut’s picture

The Taxonomy filters still show up at Enabled Filters, but the Taxonomy vocabulary Blocks no longer show up in search results. The search still works (outputs expected results) but the Taxonomy facet blocks no longer show up. What's going on?

To get out of this dilemna, I went ahead and created a new Catalog, populated it, assigned my Products to terms of it. The Taxonomy facets then showed up ok!

Then I wanted to create a new Taxonomy, and enable it as a filter. Then my new Catalog facet disappeared again!

I'm missing something.

I'm running my own SOLR install on a dedicated server. Followed all the instructions. No error to report, seems to work. Adding Taxonomy facets and involving the Ubercart Catalog seems to create a problem?

I really don't understand what's wrong here. Suspect a bug, would really like to characterize it better.

Does this help?

jpdaut’s picture

apachesolr_search_taxonomy_facet_block: $query->has_filter returns null.

Why.

jpdaut’s picture

Taxonomy filters show up but do not show newly created content (for example, products) which have been tagged to terms from these taxonomies.

Can you please help?

robertdouglass’s picture

jpdaut: could you inspect the $document variable at the end of function apachesolr_node_to_document in apachesolr.index.inc and show us the bits that have to do with taxonomy? (tid and vid fields...)

The behavior you're describing is hard to diagnose from afar. We need to see if everything is getting indexed.

jpdaut’s picture

Thank you for the hint. I inspected apachesolr_node_to_document. The node passed to it has its taxonomy as expected, however at line 36:

if ($build_document) {
// Build the node body.
$node->build_mode = NODE_BUILD_SEARCH_INDEX;
$node = node_build_content($node, FALSE, FALSE);
...,

node_build_content() returns the node w/o its taxonomy. So apachesolr_add_taxonomy_to_document() later on has no taxonomy to index.

So the question is now: what module's hook_api wipes out the node's taxonomy, and why.

Any ideas?

robertdouglass’s picture

jpdaut - you're on the verge of discovering a bug in either someone else's module or this one... too early to tell. However, it might be a bug in this module.
http://api.drupal.org/api/function/node_build_content/6

This says that it returns a structured array of the node's content... not it's meta data.

Can you please confirm that this does the right thing on a vanilla install?

If it does, you'll have to go bug hunting in your contrib modules. I'd put some debug code right in node_build_content and see when it happens.

jpdaut’s picture

Sorry for the delay. I fixed this right away for myself but forgot to come back here. There's actually only one bug that I can see, and it's in apachesolr_node_to_document(). A quick fix is at line 151 instead of:

apachesolr_add_taxonomy_to_document($document, $node);

do this:
$thenode = node_load($node->nid);
apachesolr_add_taxonomy_to_document($document, $thenode);

The problem originates at line 36 where a local variable $node is created:
$node = node_build_content($node, FALSE, FALSE);

That variable is passed to apachesolr_add_taxonomy_to_document at line 151, but that's not the right variable to pass. That's the bug.

A better fix than above would be to have a different variable name at line 36, like:
$node2 = node_build_content($node, FALSE, FALSE);

Continue building $node2. Then there's no change at line 151, no need to call node_load before. It stays:
apachesolr_add_taxonomy_to_document($document, $node);

jpmckinney’s picture

Status: Active » Postponed (maintainer needs more info)

What modules do you have installed? I looked at the code for node_build_content. The only reason $node would lose its taxonomy after passing through node_build_content is if a module implementing hook_nodeapi removes its taxonomy.

jpdaut’s picture

Thanks for confirming this. My assumptions are incorrect, then. (Robert also hinted at a bug elsewhere, in #6). I have the modules below installed. I use Apache Solr Views primarily for searching and facet navigation

********************
Drupal core 6.16
Admin Role 6.x-1.2
Administration menu 6.x-1.5
Advanced help 6.x-1.2
Apache Solr Facet Builder 6.x-1.x-dev (2010-Apr-23)
Apache Solr Search Integration 6.x-2.x-dev (2010-Jul-11)
Apache Solr Views 6.x-1.x-dev (2010-Jul-11)
Apachesolr Ubercart Integration 6.x-1.1
Authorize.net Advanced (CIM) Payment Gateway 6.x-1.x-dev (2010-Jul-11)
Content Construction Kit (CCK) 6.x-2.7
Content Taxonomy 6.x-1.0-rc2
Content Templates (Contemplate) 6.x-1.1
Date 6.x-2.4
Devel 6.x-1.21
DHTML Menu 6.x-3.5
Field Indexer 6.x-1.0
FileField 6.x-3.5
Hovertips and Clicktips 6.x-1.x-dev (2010-Jul-11)
Image 6.x-1.0-beta5
ImageAPI 6.x-1.8
ImageCache 6.x-2.0-beta10
ImageField 6.x-3.3
Javascript Tools 6.x-1.0
jQuery UI 6.x-1.3
Lightbox2 6.x-1.x-dev (2010-Jun-08)
Link 6.x-2.8
Lucid menu 6.x-1.2
Nodetype 6.x-1.0
Pathauto 6.x-1.3
Secure Pages 6.x-1.x-dev (2010-Jul-11)
SimpleMenu 6.x-1.4
Skinr 6.x-1.5
Taxonomy hide 6.x-1.02
Taxonomy import/export via XML 6.x-1.3
Taxonomy Menu 6.x-2.7
Token 6.x-1.12
Ubercart 6.x-2.3
Ubercart Addresses 6.x-1.0-rc1
Ubercart Views 6.x-3.x-dev (2010-Jul-11)
UC Upsell 6.x-1.21
Views 6.x-3.x-dev (2010-Apr-29)
Views Custom Field 6.x-1.0

adam_b’s picture

Status: Postponed (maintainer needs more info) » Active

The Taxonomy filters still show up at Enabled Filters, but the Taxonomy vocabulary Blocks no longer show up in search results. The search still works (outputs expected results) but the Taxonomy facet blocks no longer show up.

Subscribe - I'm having the same problem using v6.x-2.x-dev (2010-May-08) and would like some confirmation that the problem's fixed before I do an update. Note that other filters such as CCK fields or node attributes are appearing correctly - it's only the taxonomies which are missing.

jpmckinney’s picture

Status: Active » Postponed (maintainer needs more info)

@jpdaut: You've configured the Taxonomy hide module to hide vocabularies. This also hides them from the apachesolr module. Taxonomy hide is thus incompatible with the apachesolr module. You can create a custom module like this to patch things up, maybe:

// mymodule.install
function mymodule_install() {
  $weight = db_result(db_query('SELECT weight FROM {system} WHERE name = "taxonomy_hide"'));
  db_query('UPDATE {system} SET weight = %d WHERE name = "mymodule"', $weight + 1);
}
// mymodule.module
function mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      $node = node_load($node->nid);
      break;
  }
}

It's not a perfect solution, but it may work for you.

@adam_b: What contrib modules are you using?

adam_b’s picture

Thanks jpmckinney - I suspect I'm having the same problem as jpdaut, as I'm also hiding the vocabularies in the node display.

I'm afraid your suggestion for the custom module is a bit beyond me, though I could put it to our support company. Maybe a workaround would be to unhide the vocabulary I want, and use CSS display to make it invisible.

Any chance of a module upgrade to handle this situation? :D

If it's still relevant, the contrib modules are:

Admin 6.x-2.0-beta6
Jquery Menu 6.x-3.3
Apache Solr framework 6.x-2.x-dev
Apache Solr node access 6.x-2.x-dev
Apache Solr search 6.x-2.x-dev
Conditional Fields 6.x-1.1
Content 6.x-2.7
Fieldgroup 6.x-2.7
FileField 6.x-3.7
ImageField 6.x-3.7
ISBN 6.x-1.0-alpha2
Link 6.x-2.9
Node Reference 6.x-2.7
Number 6.x-2.7
Option Widgets 6.x-2.7
Text 6.x-2.7
Chaos tools 6.x-1.7
Page manager 6.x-1.7
Stylizer 6.x-1.7
Views content panes 6.x-1.7
Calendar 6.x-2.2
Date 6.x-2.4
Date API 6.x-2.4
Date Popup 6.x-2.4
Date Timezone 6.x-2.4
Whizzywig 6.x-1.8
Flag 6.x-1.3
ImageAPI 6.x-1.8
ImageAPI GD2 6.x-1.8
ImageCache 6.x-2.0-beta10
ImageCache UI 6.x-2.0-beta10
Typogrify 6.x-1.0
Javascript timer api 6.x-1.2
Widget: timer 6.x-1.2
SMTP Authentication Support 6.x-1.0-beta5
Menu Attributes 6.x-1.4
Menu Editor 6.x-2.1
404 Blocks 6.x-1.3
Account menu 6.x-1.7
Auto Assign Role 6.x-1.2
Automated Logout 6.x-2.5
Blocks in accordion 6.x-1.0-beta2
Book Delete 6.x-1.0
Fancy Login 6.x-1.4
Footnotes 6.x-2.3
Masquerade 6.x-1.4
Pathauto 6.x-1.3
ProfilePlus 6.x-2.0-beta2
Role Expire 6.x-1.x-dev
Role Watchdog 6.x-1.1
Session Expire 6.x-1.0
Session Limit 6.x-2.1
String Overrides 6.x-1.7
Tab Tamer 6.x-1.0
Taxonomy Access Control 6.x-1.2
Taxonomy Manager 6.x-2.2
Term Display 6.x-1.1
Token 6.x-1.13
Token actions 6.x-1.13
Vocabulary Index 6.x-2.3
Webform 6.x-2.9
Panels 6.x-3.7
Path Rules 6.x-1.1
Rules 6.x-1.2
Google Analytics 6.x-2.2
Taxonomy Import/Export via XML 6.x-1.3
ThemeKey 6.x-2.4
jQuery UI 6.x-1.3
DraggableViews Book handler 6.x-3.4
Views 6.x-2.11
Views Accordion 6.x-1.3
Views Bulk Operations 6.x-1.9
Views UI 6.x-2.11

(Ubercart)
Cart 6.x-2.3
Conditional Actions 6.x-2.3
Order 6.x-2.3
Product 6.x-2.3
Store 6.x-2.3
Payment 6.x-2.3
Reports 6.x-2.3
Roles 6.x-2.3
Shipping 6.x-2.3
Shipping Quotes 6.x-2.3
Tax Report 6.x-2.3
Taxes 6.x-2.3
Not for sale flag 6.x-1.4
Price per role 6.x-1.0
Terms of Service 6.x-1.1
Ubercart Addresses 6.x-1.0
uc_views_addresses 6.x-3.0
VAT 6.x-1.1
Flatrate 6.x-2.3
Credit Card 6.x-2.3
Free Order 6.x-1.0-beta4
PayPal 6.x-2.3
Ubercart Views 6.x-3.0

jpmckinney’s picture

@adam_b: Which module are you using to hide the vocabularies in the node display?

adam_b’s picture

jpmckinney’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Marking duplicate.

adam_b’s picture

FWIW, I'm having the same problem with http://drupal.org/project/term_display. There are no issues logged for that module concerning Solr.

jpdaut’s picture

Thank you jpmckinney, I confirm that Taxonomy hide was the problem. The fix in #8 is not needed, apachesolr_node_to_document() is fine.

However another problem has surfaced: the facet field links are missing a tid argument. My set-up is as in http://acquia.com/blog/views-3-apache-solr-acquia-drupal-future-search. My view is called browse, so if a facet field link should be browse/tid1,tid2 instead it is just browse/tid1

This all worked just fine before I did 3 things:

1) Added a custom sort (implemented a small module as per http://acquia.com/node/1096594 and other places). However Views gave me warnings: "The Apache Solr search engine is not available" so I took this out to revisit later.

2) Took out Taxonomy hide

3) Deleted the index, rebuilt it.

In debugging I do see in apachesolr_search_nested_facet_items() that
$options['query'] = $new_query->get_url_queryvalues();
is empty. No filters tids.

If I use the default search at search/apachesolr_search, everything is fine.

But I want to use my View. What is going on? Why did it stop working?

jpdaut’s picture

Never mind this. I'll never know what went wrong. Lack of time, I decided to forget it and reverted to my last backup which works.

soghad’s picture

There is an issue with taxonomy_hide. See #827696: Taxonomy Hide & Apache SOLR Search Integration

Anonymous’s picture

Version: 6.x-2.0-beta2 » 6.x-2.0-beta3
Status: Closed (duplicate) » Active

Re-opening. Taxonomy Hide used to be the problem in 6x.beta2. But a few days ago I upgraded to 6x.beta3 and taxonomies are no longer indexed. Im not using taxonomy hide anymore.

The facets show up at Enabled Filters, and the blocks show up in the blocks admin.

However in /admin/reports/apachesolr -- no "im_vid_x" data is listed. The taxonomy data is not indexed anymore.

Anonymous’s picture

Reverting to 6x-beta2 solved my problem (with a full uninstall - reinstall - reindex cycle). Taxonomy data is indexed again. It also brought back all the CCK fields (they were also missing completely from the "Enabled Filters" page). Is it possible to unpublish a module version in CVS? I would suggest to do so, beta3 will mess up a lot of people's work!

robertdouglass’s picture

Version: 6.x-2.0-beta3 » 6.x-2.x-dev

@morningtime, let's keep the issue on the dev branch as that's where fixes occur. Thanks.

jpmckinney’s picture

Status: Active » Postponed (maintainer needs more info)

I have been using the latest 6.x.2x-dev releases for a long time, and I have never had trouble making taxonomy or CCK filters show up.

Can you reproduce the issue with a clean Drupal install using a clean Solr install? If not, there's a conflict with a contrib module (like we discovered with taxonomy_hide), or a conflict with a custom module.

fonant’s picture

Me too, vocabularies that have their display modified by term_display don't appear in the search index.

The first fix in #10 works here, though :)

Bilibul’s picture

Hi all,

I faced the same issue. This was due to taxonomy_access module and taxonomy access rights applied to the anonymous role. I set this role not to be able to list terms of any vocabulary (default general settings) but did not consider the cron task is run anonymously. Granting term listing to the anonymous role solved the issue.

Anonymous’s picture

The solution from #10 is still needed in the latest December's 6x2x-devx...! Why hasn't it been comitted?

jpmckinney’s picture

Status: Postponed (maintainer needs more info) » Fixed

If you use other modules to hide taxonomies/change taxonomy displays, then those taxonomies will also be hidden/changed with respect to Solr. I'm sure some people do want these taxonomies to be hidden from both Solr and node displays. Clearly, some people on this thread want taxonomies hidden from node displays, but not from Solr. Unfortunately, this module can't determine which is which. You can raise the issue with whatever module is being used to hide the taxonomies. The apachesolr module will not support the half-dozen modules that let you do this.

jpmckinney’s picture

We may properly fix the issues around the use of node_build_content in #382878: Render $node->teaser before sending it to Solr.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.