Closed (fixed)
Project:
Search Lucene API
Version:
5.x-1.6
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Oct 2009 at 13:06 UTC
Updated:
19 Feb 2010 at 23:40 UTC
Hi,
I used successfully search lucene api for cck fields, as date or text.
Now, I need to insert a node reference cck field into a lucene search form.
How can I obtain it? I tried with similarity with taxonomy that runs like this:
$tids = array();
foreach ($node->taxonomy as $taxonomy) {
$tids[] = $taxonomy->tid;
}
if (!empty($tids)) {
$text = implode(' ', $tids);
luceneapi_field_add($doc, 'unstored', 'category', $text, TRUE);
}
but with a cck node reference it doesn't work:
$nids = array();
foreach ($node->field_rif_author as $author) {
$nids[] = $author['nid'];
}
if (!empty($nids)) {
$text = implode(' ', $nids);
luceneapi_field_add($doc, 'unstored', 'author', $text, TRUE);
}
Comments
Comment #1
cpliakas commentedHi Alex.
Are you looking to be able to retrieve the referenced nid back from the index when results are returned, or are you looking to be able to search by the referenced nid?
Thanks,
Chris
Comment #2
alex72rm commentedHi again and thanks for your answer.
I need the second one, search by referenced nid. I have a list of content authors (a many-to-many relation between a story cck content type and an author cck content type). So, each story can have one or more authors.
I wish to search stories with a range of publication dates (that are different from content submit date, and rendered with cck date field) - this works already.
Then with taxonomy arguments - this works already.
And then with a list of potential authors (the full list) rendered with a drop down list ( couple, the second one is visible into list).
But... it doesn't work. The similarity of code with taxonomy snippet doesn't apply with referenced nodes.
Comment #3
cpliakas commentedHi Alex.
Sorry for the late response. In terms of node reference, do you want to index content in the referenced node, of do you want to index the referenced nid? If you want to index the referenced content, this gets tricks as you have to load and index the content in the referenced node. You then have to come up with a custom mechanism to update the modification timestamp on the parent nid every time a reference is added or changed. Does this make sense?
I am actually looking into something similar, so let me know what the exact use case is and I can help you out.
Thanks,
Chris
Comment #4
alex72rm commentedHi again,
I need the simplest one, I should index the referenced nid, when multiple ones can be selected from a dropdown list inserted into advanced luceneapi search expandable block.
By the way, I select the human-readable string, but the couple is rendered into the dropdown list, therefore I need only the nid.
Thanks a lot for your help!
Comment #5
cpliakas commentedThis snippet of code should work. It indexes all node reference IDs and stores them in a Lucene field matching the CCK field name. You can modify the logic to fit your purposes.
Hope this helps,
Chris
Comment #6
cpliakas commentedA project has been set up at http://drupal.org/project/luceneapi_cck to index CCK data. I would be interested for someone to contribute support for node reference IDs.
Comment #7
cpliakas commentedClosing after a long period of inactivity.