In hook_apachesolr_query_prepare,add ur indexed field with ur weightage using param bf
.
This hook is similar to the query_alter but runs before the query is cached
Reference to parameters https://cwiki.apache.org/confluence/display/solr/Common+Query+Parameters
/**
* Prepare the query by adding parameters, sorts, etc.
*
* This hook is invoked before the query is cached. The cached query is used
* after the search such as for building facet and sort blocks, so parameters
* added during this hook may be visible to end users.
*
* This is otherwise the same as HOOK_apachesolr_query_alter(), but runs before
* it.
*
* @param object $query
* An object implementing DrupalSolrQueryInterface. No need for &.
*/
function module_apachesolr_query_prepare(DrupalSolrQueryInterface $query) {
$query->addParam('bq','indexedFieldName^20');
watchdog("solrquery", '<pre>' . print_r( $query, true) . '</pre>');
}
I have used
$query->addParam('bq','tm_display_name^20');
bq: Boost Query: specifies a factor by which a term or phrase should be "boosted" in importance when considering a match.
Where solrquery obj results like that
[bq] => Array
(
[0] => tm_display_name^40
)
Assuming that field is already indexed in our solr.
Use that hook. Then search for a content. In recent log message 'solrquery',check
whether your field is added in bq
Have added the link for you reference.
http://www.computerminds.co.uk/articles/boosting-solr-search-results-query-time