I am having some trouble with creating a search module (dictionary) that uses apache solr. The current module is connected to a solr instance from a different source that has a indexation from a postgresql database with it's own schema.
Now I'm in the process migrating all the content to nodes in Drupal and so far so good. The thing now is that I need to change the search request from the current solr to Drupal apachesolr with its standard schema. Problem is that I am relative new to how solr works, but I do understand the basic structure.
Anyone that might be able to give me a hand or point me to some kind of documentation to how to do this?
I tried to change the query search quartiles from what i could find in the schema . The only thing keep getting when i do a search is "Your search yielded no results"
Here is the cod in the callbacks.inc file unmodified
<?php
function ne_norstedts_page($types) {
$ret = '';
$form = drupal_get_form('ne_norstedts_search_form', $types);
// Render search form.
$ret .= '<div id="norstedts-search-form" class="fourcol">';
$ret .= render($form);
$ret .= '</div>';
// Get search results and output them
isset($_GET) ? extract($_GET) : '';
if (isset($q) && isset($from) && isset($to) && isset($type)) {
$query = array(
'q' => $nq,
'fq' => 'type:norstedts AND subtype:' . $from . '-' . $to . '-' . $type,
'start' => isset($page) ? ($page) * 10 : 0,
);
$result = ne_api_get_api_fetch('/search', $query);
$title = '';
foreach ($types as $t => $name) {
if ($t == $type) {
$title = $name;
break;
}
}
$ret .= theme('ne_norstedts_results', array('result' => $result['result'], 'title' => $title));
}
return $ret;
}
/**
* Gets text for a single word for ajax
*/
function ne_norstedts_ajax_load_word() {
$url = isset($_GET['url']) ? $_GET['url'] : '';
if ($url) {
$result = ne_api_get_api_fetch($url);
if (isset($result['text'])) {
echo drupal_json_encode($result['text']);
}
}
exit;
}
and here is my modified version of it
<?php
function ne_dictionary_page($types) {
$ret = '';
$form = drupal_get_form('ne_dictionary_search_form', $types);
// Render search form.
$ret .= '<div id="dictionary-search-form" class="fivecol">';
$ret .= render($form);
$ret .= '</div>';
// Get search results and output them
isset($_GET) ? extract($_GET) : '';
if (isset($q) && isset($from) && isset($to) && isset($type)) {
$query = array(
'q' => $nq,
'fq' => 'site:' . $from . '-' . $to,
'start' => isset($page) ? ($page) * 10 : 0,
);
$result = apachesolr_search_search_page('/search', $query);
$title = '';
foreach ($types as $t => $name) {
if ($t == $type) {
$title = $name;
break;
}
}
$ret .= theme('ne_dictionary_results', array('result' => $result['result'], 'title' => $title));
}
return $ret;
}
/**
* Gets text for a single word for ajax
*/
function ne_dictionary_ajax_load_word() {
$url = isset($_GET['url']) ? $_GET['url'] : '';
if ($url) {
$result = apachesolr_search_search_page($url);
if (isset($result['text'])) {
echo drupal_json_encode($result['text']);
}
}
exit;
}