I've installed apachesolr,search api solr and views. I have only indexed article and basic page content type.

Then i've added new field "internal use only" as checkbox for article content type. I want to add filter "internal use only" only in article content type. I want to show except those articles.

How to alter apache query?

1 Answer 1


Check apachesolr.api >> hook_apachesolr_query_alter

function hook_apachesolr_query_alter(DrupalSolrQueryInterface $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');

More details about solr query DrupalSolrQueryInterface

  • How to do this?
    – Guru
    Commented Oct 5, 2015 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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