1

I want to alter apache solr search query with my custom filed.

I have custom content type called "Restaurant" and in this content type i have 1 field called "country". Now I want to add condition that display search result only those restaurant which is belong to "Jamaica" and display facet as per this condition.

So,how can I alter query with apache solr serach?

2

You can use hook_apachesolr_query_alter()

Alter the query after it's prepared and cached.

Example from the docs page

function hook_apachesolr_query_alter($query) {
  // I only want to see articles by the admin.
  //
  // NOTE: this "is_uid" filter does NOT refer to the English word "is"
  // It is a combination of flags representing Integer-Single, which is
  // abbreviated with the letters i and s.
  //
  // @see the <dynamicField> definitions in schema.xml or schema-solr3.xml
  $query->addFilter("is_uid", 1);

  // Only search titles.
  $query->replaceParam('qf', 'label');
}
| improve this answer | |
  • Thanks but i want to join table how can i do this? – Pranav Gandhi Jan 7 '14 at 10:50
  • Not a clue I'm afraid - see what type $query is and inspect the class methods, you should be able to find something there – Clive Jan 7 '14 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.