Indexing options for taxonomy
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | search.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | patch (code needs work) |
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. ;-)
| Attachment | Size |
|---|---|
| indexing_options.png | 17.61 KB |

#1
Now the patch.
#2
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.
#3
Changed three lines that did not comply with coding standards.
#4
Updated for latest HEAD.
#5
Anyone else interested in reviewing this patch before someone rewrites the search module? :-) The patch still applies, for now.
#6
subscribing
#7
#8
Subscribing.
See also http://drupal.org/project/synonyms for a current (Drupal 5) implementation of part of this request.
#9
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
#10
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().#11
I like the concept. However, I think the form should be implemented via form_alter and not with an if(module_exists('search')).