Searching on CCK fields
jandoemen - March 19, 2007 - 00:03
| Project: | Content Construction Kit (CCK) |
| Version: | 5.x-1.4 |
| Component: | General |
| Category: | support request |
| Priority: | normal |
| Assigned: | haraldessert |
| Status: | closed |
Jump to:
Description
Hi,
I spent about 5 hours looking for a solution to make CCK field content searchable. The only thing I found was to put all field in the body field.
Is there a better way to include CCK field in a search? I read in some discussion a suggestion to give all CCK field a checkbox whether to include that field in the search.
Can someone shine some light on this please?
Thanks in advance
Jan

#1
The CCK Field Permissions module seems to allow searching cck fields / sub fields. Unfortunately, private fields are also indexed. Private fields do not show up in the search results if the user doesn't have permission to see them, but the nodes with matching fields do show up.
#2
I do not get what the initial post is about. CCK fields do get indexed.
The problem is rather that too much gets indexed : field labels are indexed as well, which you generally don't want.
Unfortunately, this is a core issue - when the node is rendered for indexing, CCK has no way to differentiate this from a regular 'full node' view, so you get the labels.
As for the 'CCK field perms' mentioned in #2, I'm afraid this just means that that the indexed fields are the ones the 'cron user' (anonymous, if I'm not mistaken) is allowed to see, which does not completely makes the trick.
What we actually need here is a 'search index' rendering style - see eaton's http://www.drupal.org/node/144608 and http://www.lullabot.com/blog/trouble_nodes
#3
#4
I don't think this is fixed!!
I made a CCK field to fill just with words related with the node, that not necessarily are contained in the body field.
In 'Display fields' I set this key-word text field to be hidden, since I didn't want it to show up in the node. I wanted this field just to be indexed in the search results.
BUT IT DOESN'T !!!
-------------------------------
For example:
I created an image node, containing the picture of a stone. The body explains about the picture, the kind of stone, etc. And in my 'key-word' field I put related words that don't appear in the body, but could be helpful for someone to search pictures in my site, like: rock, stoney, hard, etc.
But when I search the word 'rock', that is not mentioned in the body, but just in the hidden cck text field, there are no results.
-------------------------------
So I guess we STILL HAVE an issue here. And I think this is really important.
Maybe, not just text fields should appear in the search results, but also image fields!! (That'd be awsome!!)
Has anyone already solved this?
#5
did you run cron? how much of your site is indexed. I'm pretty sure everything you want to happen - happens.
#6
Yes!! I've already tried to run cron.
And 100% of the site is indexed.
But there are still no results!! I've also tried to make the field visible again (just for the try) and then run cron. But there was nothing different.
Still trying, here.
If you wish to try, the site is here:
www.kphotos.com.br/photo
It's still in development.
For example, the node called Zoom numa pedra has a description containing just the word stone (cause it's a picture of a stone), and I put the word 'rocha' (rock, in portuguese) within the keywords to make it easier to find it, even with other words.
Give it a try, and you'll see, that it doesn't return any results.
I just can't see why :S
#7
The word "rock" or "rocha" doesn't seem to appear anywhere in the node output on that page that I can see. So I really doubt it would make it into the index if it doesn't appear on the node. Assuming you put it into some "description" field, make sure that field is rendered in some way on the node, then reindex and try searching.
#8
I'm having the same problem.
In my case I've added a "credits" field for each "game" node type. I render this field in my custom template using:
<?phpprint content_format('field_credits', $field_credits[0], 'default' )
?>
The site is fully indexed. And when I make a search I never get data from "credits" fields.
You can check it here: http://www.pixelgordo.com/juego/full-throttle
At the top, if you click on "mostrar crédidos" you can see the field properly rendered (it's shown/hidden by jquery). But if you search for "Tim Schafer" you won't get any result. Help picture here: http://img397.imageshack.us/my.php?image=capturacy9.png
I'm using a plain cck installation without any extra fields from other projects.
#9
The word 'rocha' is really in no output of my node, beacuse I hid it in the 'Display fields' settings.
It is in my 'key-word' text field, that shouldn't really appear anywhere, except in the search results.
The 'description' text field appears on the left-sidebar when you open a picture, right under the node title. So it IS rendered. But it still doesn't appear in the search results.
But I thought of something: I also hid this 'description' field, like I did with my 'key-word' field, in the 'Display fields', beause I didn't want it to be shown in the node. But I recall it using the command:
<?phpprint $node->field_descricao[0]['value'];
?>
within my page.tpl.php file.
So I could display it somewhere else on my page, without beeing IN the node output. I think it just doesn't appear in the results because it is hidden!!
So I tried making it visible, and then I re-indexed the site and BADABIN-BADABUM, there it appeared in the results.
Now I guess the only way I have it not to be shown in the node display (just in my left-sidebar) and still show it in the search results is making it with
visibility:hiddenin the CSS file.It's kinda dirty... But what else is left??
#10
I think we can leave this explanation text here on the end, if anyone agrees:
1) CCK fields that are set as hidden in the 'Display fields' configurations DON'T appear in the search results, even if you render it somewhere else on your custom page. You can re-index your site and it just won't appear.
2) Although you don't want this field to appear in your node display, if you need it to be shown in the search results you'll have to make it visible in the 'Display fields' settings and hide it somehow else.
Not even drupal is perfect!! =D
But we just love it, don't we??
Thx, folks!!
#11
Yes, it works ;). It's not the perfect solution but it's a good workaround.
Kind regards and thanks a lot for your help.
#12
Really not the perfect solution!! ;)
Maybe anyone has another answer, more soffisticated!!
Y que sitio hermoso el tuyo, Macarro!! Avisanos cuando está listo!!
#13
Well if you want some good information on how search indexing works in Drupal check out:
http://acquia.com/blog/drupal-search-how-indexing-works
#14
Muchas gracias, haraldessert ;)
Thanks a lot. I'm working on it at spare time and for a mix between fun and learning. I need to add some new content types with their little customized templates and finally build the relations between them. I'll post my progress here: http://drupal.org/node/295359
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
temp
Automatically closed -- issue fixed for two weeks with no activity.
#15
Automatically closed -- issue fixed for two weeks with no activity.
#16
Thanks for that, Moonshine!!
Taking a look at that post about Drupal Search.