Closed (fixed)
Project:
Apache Solr Search
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Jun 2010 at 20:50 UTC
Updated:
4 Mar 2012 at 17:22 UTC
Hello,
CCK text fields are not indexed with nodes when running cron, when indexing all nodes.
How to index them?
If we have a text field into a indexed node with the value "Potatoes", we should find this node when we search the word "Potatoes", right?
There are a lot of CCK field available as filters but not text field. Why?
Comments
Comment #1
jpmckinney commentedIf the CCK field uses a text widget, then it can contain all kinds of values. So, it is not a good candidate for faceting.
If the CCK field uses a select widget, then it contains a fixed number of values. So, it is a good candidate for faceting.
We only index CCK fields if they are good candidates for faceting.
Now, for your problem: when you search for "Potatoes" with the apachesolr module, it looks for occurrences of "Potatoes" in the document's body field. This field contains the rendered node:
It also contains any content added by modules using the 'update index' case of hook_nodeapi.
So, if your CCK text field that contains "Potatoes" is not rendered with the node, then you should either implement hook_nodeapi or hook_apachesolr_update_index to add it to the document's body field.
Comment #2
junro commentedok, sure cck text fields can't be use for faceting. I just want to index them.
Ok, but how to do it?
The code should be in apachesolr.index.inc. But I'm just a newbie in code and I don't really know what code I should write, and where to put it.
Thanks :)
Comment #3
jpmckinney commentedWith hook_apachesolr_update_index you can do:
This may cause the CCK field content to appear in your search snippets, though.
Comment #4
junro commentedOk, so I put the code at the end of apachesolr.index.inc file:
but MYMODULE, I must to replace it by what?
Comment #5
jpmckinney commentedYou have to create a custom module and put it there: http://drupal.org/developing/modules
Comment #6
junro commentedThanks for your help, but I don't thing I'm able to create a custum module by myself :(
Comment #7
jpmckinney commentedComment #8
jpmckinney commentedMarked http://drupal.org/node/744858 duplicate.
Comment #9
pwolanin commentedComment #10
jangolden commentedThis worked great for me...thanks. However, my results were showing img tags.
After a little digging, I realized I need to use 'view' instead of 'value' to recognize the display formats (in search tab) that I set for this field.