Hướng dẫn Integrating multisite Drupal với Apache Solr

Hướng dẫn Integrating multisite Drupal với Apache Solr

There are a number of ways this can be solved with Drupal 7:

1. Use a search core per site

Using this approach, you create an unique Solr core (N.B. a single Solr application can contain 0 or more cores) per site and either:

to connect the appropriate search cores to the appropriate Drupal environments. Then you can enable (but not no need to configure) the apachesolr_multisitesearch module.

Pros

  • Each site’s index is isolate from each other, so there is no interfering with other indexes, and no ability to drop other indexes
  • You can customise the Solr config per core

Cons

  • Need to provision a new Solr core every time you add a new site
  • Need to change settings.php every time you add a new site

2. Use a single shared core, and apachesolr_multisitesearch

In this option you utilise a single shared Solr core, and send the documents from all sites into it. Using special attributes on the documents, you are able to query and get only the results you desire back out again.

The module you need to enable is apachesolr_multisitesearch. Just enabling the module makes your standard search pages return results only for your site. This is accomplished internally by adding a filtering query to each Solr query using hook_apachesolr_query_alter().

You can see the site hashes are different based on the base_url in Drupal already.

Example of this working

Note the site hashes are different:

$ drush --uri=www.example1.com vget apachesolr_site_hash
apachesolr_site_hash: 'lm0ujj'

$ drush --uri=www.example2.com.au vget apachesolr_site_hash
apachesolr_site_hash: '9qt6o6'

Example of this not working

Note the site hashes are the same, thus the search results will be blended:

$ drush --uri=www.example1.com vget apachesolr_site_hash
apachesolr_site_hash: '92ub55'

$ drush --uri=www.example2.com vget apachesolr_site_hash
apachesolr_site_hash: '92ub55'

You will find yourself in this predicament if you clone new sites from old sites (thus the database variable persists).

In order to fix blended site hashes

  1. drop the current index (both sites)
  2. delete the variable ‘apachesolr_site_hash’ (both sites)
  3. visit the admin page solr page (both sites) - this will regenerate the site hash
  4. verify the site hash is now different (both sites)
  5. reindex (both sites)

Pros

  • No need to provision a new Solr core every time you add a new site
  • No need to change settings.php every time you add a new site
  • Hooks into the delete query to prevent dropping the entire index

Cons

  • You need to ensure the site hash is different for each site, so if you clone one, you will need to delete the variable apachesolr_site_hash straight away
  • If you ever drop Solr’s index, this will drop all documents across all sites. This should be hard to do (you will need to disable the apachesolr_multisitesearch module)
  • You must share Solr config (e.g. the schema XML), so you cannot change this per site

Comments

If you run a multisite setup, and make use of Apache Solr, I am keen to hear how you integrated it, and if you have any tips or tricks to share.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Google Calendar Thêm Tính Năng Gợi Ý Thời Gian Cho Sự Kiện

Google Calendar Thêm Tính Năng Gợi Ý Thời Gian Cho Sự Kiện

Tạo một sự kiện hay một lịch họp không khó nhưng lựa chọn được thời gian thích hợp sau cho tất cả khách mời đều có thể tham gia ...

www.drupalvietnam.org chính thức ra mắt tại Việt Nam

Website drupal vietnam (dot) org chính thức ra mắt tại Việt Nam

Hệ quản trị nội dung (CMS) Drupal đã trải qua 10 năm phát triển, xuất sắc đạt danh hiệu “CMS nguồn mở tốt nhất” vào năm 2007, 2008 và CMS mã nguồn mở PHP tốt nhất vào năm 2009 trong cuộc bình chọn của Packt Publishing.

Renren

Mạng xã hội Renren - Khắc tinh của Facebook tại China

Việc chính phủ Trung Quốc ra tay chặn Facebook tất nhiên không thể cản nổi bước tiến của những cư dân mạng sinh hoạt trên mạng xã hội lớn nhất thế giới này. Mặc dù cộng đồng người sử dụng Facebook ở Trung Quốc có số lượng khá ít ỏi. Theo thống kê, hiện có khoảng 295.400 người ở Trung Quốc đang sử dụng Facebook. Điều này có nghĩa là cứ 10.000 người sử dụng internet ở Trung Quốc thì có 7 người có tài khoản Facebook đang sử dụng.

Công ty diệt chuột T&C

 

Diet con trung