How to set domain based search using search_api_solr? I am using Domain and Search API Solr module in my project. On all domains, searching for a content gets result(content) from all domains. I would like to get search results according to the domain.
For example, if a user is on domain a.domain.com, then the search should return content which is published on a.example.com only and not on any other domains or sub-domains.
You could take a look at Search API Domain Access sandbox project:
https://www.drupal.org/sandbox/raf/2244229

I did a work around based on that code that worked for me:

&lt;?php
/**
 * Implements hook_entity_property_info_alter().
 *
 * Adds an entity property for the domain access of the node.
 *
 * @TODO this is just a workaround @see https://www.drupal.org/sandbox/raf/2244229
 */
function my_module_entity_property_info_alter(&amp;$info) {
  $properties = &amp;$info['node']['properties'];
  $properties['my_module_domain_access'] = array(
    'label' =&gt; t('My Domain Access Information'),
    'description' =&gt; t('The domains to which the node is published.'),
    'type' =&gt; 'list&lt;integer&gt;',
    'getter callback' =&gt; 'my_module_get_domain_info',
  );
}

/**
 * Custom getter callback for the domains in
 *
 * @param $data
 * @param array $options
 * @param $name
 * @param $type
 * @param $info
 * @return null
 */
function my_module_get_domain_info($data, array $options, $name, $type, $info) {
  return (!empty($data-&gt;domains) ? $data-&gt;domains : NULL);
}

/**
 * Implements hook_search_api_query_alter().
 *
 * Adds a filter for the current domain.
 */
function my_module_search_api_query_alter(SearchApiQueryInterface $query) {
  $domain = domain_get_domain();
  $query-&gt;condition('my_module_domain_access', $domain['domain_id']);
}


Now, you will be able to choose the field for indexing under "admin/config/search/search_api/index/your_index/fields" and in query time this code will filter out data based on current domain, not many more things.

Hope it helps, but notice that this code it is not fully tested (nodes that have been published in more than one domain... etc).