For one of my projects, I need taxonomy terms to get very high scores in the search index. The current default is to assign taxonomy terms the same ranking as <strong> text, and the user cannot change this default.

This patch adds a new group of options to the vocabulary form (see the snapshot). These let the user choose what kind of ranking the terms should get, or decide to not index the terms at all.

Similar options are offered for synonyms (hey, nice to use them!), parent terms, and synonyms of parent terms.

Say I have a term "Montréal", with "Québec" as parent, which in turn has "Canada" as parent. When a node uses the term "Montréal", I want "Québec" and "Canada" to be indexed as well, but with a lesser ranking. These options let me do that.

Now, I'm not sure the average Drupal user cares about such options, that's why I made them collapsed by default. If people believe this does not belong to taxonomy.module, I'll be glad to move it to an external module given some way to override function taxonomy_node_update_index().

Improvement suggestions are also welcome. ;-)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David Lesieur’s picture

FileSize
8.81 KB

Now the patch.

chx’s picture

Component: taxonomy.module » search.module

I massively like this patch. Some Drupal users, indeed, may not care. But some may :)

But, of course, the final decision is of Steven's, as this more belongs to search than taxonomy and I recategorized as such.

David Lesieur’s picture

FileSize
8.81 KB

Changed three lines that did not comply with coding standards.

David Lesieur’s picture

Version: x.y.z » 6.x-dev
FileSize
12.74 KB

Updated for latest HEAD.

David Lesieur’s picture

Anyone else interested in reviewing this patch before someone rewrites the search module? :-) The patch still applies, for now.

guardian’s picture

subscribing

David Lesieur’s picture

Version: 6.x-dev » 7.x-dev
mlncn’s picture

Subscribing.

See also http://drupal.org/project/synonyms for a current (Drupal 5) implementation of part of this request.

birdmanx35’s picture

Status: Needs review » Needs work

No surprises here, but this fails against HEAD:

$ patch -p0 < indexing_options_1.patch
patching file modules/taxonomy/taxonomy.module
Hunk #1 FAILED at 271.
Hunk #2 FAILED at 331.
Hunk #3 FAILED at 360.
Hunk #4 FAILED at 373.
Hunk #5 succeeded at 1240 (offset -121 lines).
4 out of 5 hunks FAILED -- saving rejects to file modules/taxonomy/taxonomy.module.rej
patching file modules/search/search.module
Hunk #1 succeeded at 1171 (offset 59 lines).
patching file modules/system/system.install
Hunk #1 FAILED at 578.
Hunk #2 FAILED at 1048.
Hunk #3 succeeded at 2475 with fuzz 2 (offset -1013 lines).
2 out of 3 hunks FAILED -- saving rejects to file modules/system/system.install.rej

David Lesieur’s picture

It doesn't feels like this feature has raised enough interest to justify updating the patch for D7...

Rather than implementing this specific logic, it might be preferable to just give a way for modules to override taxonomy_node_update_index().

robertDouglass’s picture

I like the concept. However, I think the form should be implemented via form_alter and not with an if(module_exists('search')).

coupet’s picture

Subscribing. see also:

Search Ranking
http://drupal.org/project/search_ranking

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev

Well, this didn't make it into Drupal 7, and it is past time for feature requests now... sorry. I'm putting it on the consideration list for Drupal 8.

jhodgdon’s picture

Title: Indexing options for taxonomy » Ranking options for taxonomy
jhodgdon’s picture

Status: Needs work » Closed (won't fix)

Doing this in Drupal 7/8 will not be viable, because taxonomy is attached to nodes via the field system. One piece of the functionality is available already though: since taxonomy is in fields, you can include/exclude a particular taxonomy field from search indexing by defining whether or not it is displayed in the Search Index display format.

The rest of this can't be done this way. However, a custom module could probably do something similar by using node hooks to affect how a node with a taxonomy field is viewed in the Search Index display type. For instance, it could give the admin a choice of displaying it in various HTML tags, which would increase or reduce its weight when indexing.

Anyway, as far as Core Search/Taxonomy is concerned for 8, I'll have to mark
this as "won't fix".