YaCy で独自の検索エンジンを構築する

05/24 2022
YaCy ウェブサイトのスクリーンショット
(画像:©YaCy)

Mainstream search engines like Google are pretty good at what they do, but many people choose not to use them because of privacy concerns. Then there are those who are concerned about content falling through the cracks just because the creator hasn’t followed the best practices for search engine optimization (SEO).

YaCy (opens in new tab), an open source distributed search engine, works pretty much like its mainstream peers, but doesn’t suffer from any of their ills. YaCy uses a peer-to-peer (P2P) network, so every user running an instance of the search engine joins in the effort to index the internet. The index is distributed and redundant across all YaCy users.  

To further bolster its privacy credentials, YaCy ensures that no one can tell who has searched for what words, in essence making all searches functionally anonymous. 

YaCy only indexes publicly accessible, non-password-protected pages. You can also use it as a search engine for your website, or use it to index pages on the intranet, which it ensures aren’t accessible to anyone outside your network. 

Installation

YaCy is written in Java and runs on Windows, macOS, and Linux. Search engines are complex beasts, but thanks to YaCy’s distributed nature, you don't need a fast machine, nor a lot of space to run a YaCy client. 

Installation is fairly simple. Before you begin, ensure you have Java installed on the machine. Windows and macOS users can obtain pre-built binaries from Adoptium (opens in new tab), while Linux users can pull it from their official repositories.

For instance, Debian users can use sudo apt install default-jdk, while Fedora users can search for the available versions with sudo dnf search openjdk, before installing the latest version with sudo dnf install <openjdk-package-name>.

Once you have Java installed, download the YaCy executable (opens in new tab) for your platform, and extract it. For instance, the command sudo tar --extract --file  yacy_*z --directory /opt -v, will extract the installer under the /opt directory on Linux. Now simply change into the extracted directory and start YaCy:

# cd /opt/yacy

# ./startYACY.sh

YaCy is now running on port 8090 on your computer. Fire up a web browser, and head to http://localhost:8090 to access the YaCy instance. You can now search the internet just as you would using a regular search engine.  

Crawl the internet 

There's much more you can do with the YaCy search engine than just search passively. For instance, since P2P indexing is user-driven, you can ask YaCy to crawl any website. 

To access the advanced administrative controls of your search engine, click the Administration button in the top-right corner. This brings up the admin panel, which among other things lets you tweak how your YaCy instance interacts with other YaCy clients in the network.

To initiate a manual web crawl, navigate to Load Web Pages, Crawler option under the First Steps menu. Enter the URL in the space provided and hit Start New Crawl. As the crawler gets underway, it’ll start showing all kinds of statistics about the crawl, and you can scroll down to view the structure of the scrolled website graphically. 

After initiating the crawl, head to Monitoring > Index Browser to view how many pages have been indexed and view other details, such as their name and number of outbound links.  

現時点ではデフォルトのオプションを使用し、YaCy に慣れてきたら、クローラーの制限などの他のオプションを検討してください。検索エンジンは複数のクロールを同時に実行でき、「ファースト ステップ」セクションからクロールを順番に開始することも、「運用」>「高度なクロール」に移動して複数の Web サイトを同時にクロールすることもできます。 

クロール ジョブが開始されると、YaCy は入力された URL のインデックスを作成し、そのインデックスをローカル マシンに保存します。世界中の YaCy ユーザーがインデックスを利用できるようにするには、YaCy の P2P ネットワークに参加する必要があります。 

このためには、ルーターのファイアウォールでポート 8090 を開く必要があります。ルーターの管理ページにログインし、ファイアウォールまたはポート転送を制御する設定パネルを探します。 

ルーターのファイアウォールの設定を見つけたら、ポート 8090 をホワイトリストに追加します。ルーターがポート転送を実行している場合は、同じポートを使用して、受信トラフィックをコンピューターの IP アドレスに転送する必要があります。

YaCy ネットワークに参加した後、[ Advanced Crawler]の下の[Do Remote Indexing]オプションを切り替えることができます。これにより、クライアントはインデックスを作成している URL をブロードキャストできるようになり、リクエストを受け入れることを選択したネットワーク上の他のクライアントがクロールの実行を支援できるようになります。

あなただけの Google 

Web を検索する代わりに、YaCy を使用して独自のデータを検索したり、企業イントラネット内のローカル ファイル共有の検索システムを実装したりできます。 

このためには、YaCy を内部インデクサーとして実行する必要があります。これらのモードでは、ローカル ネットワーク内のユーザーのみが YaCy のパーソナライズされたインスタンスを使用して共有ファイルを検索でき、データはネットワーク外部のユーザーと共有されません。

[管理] > [最初のステップ] > [ユースケースとアカウント]に進みます。ここでは、YaCy のインターフェースの言語などの基本的な詳細を指定できます。 

ここから YaCy インスタンスの動作を変更することもできます。デフォルトのオプションでは、クライアントを YaCy のグローバル P2P ネットワークの一部として使用して、Web のクロールとインデックス作成を支援します。 

独自の Web サイトの検索ポータルを作成するには、 [独自の Web ページの検索ポータル]オプションを選択する必要があります。次に、下にスクロールして「設定を設定」ボタンを押します。次に、ドメインをクロールして、検索ツールで利用できるコンテンツを生成する必要があります。

検索を Web サイトに統合するには、左側の列を[検索ポータルの統合]セクションまで下にスクロールします。[ポータル設定]ページが表示され、ここから企業ブランドを使用して YaCy の外観をカスタマイズして Web サイトに溶け込ませることができます。完了したら、「検索ページの変更」ボタンを押します。生成された iframe コード スニペットのいずれかを使用して、YaCy を利用したカスタマイズされた検索を Web サイトに統合できるようになりました。

同様に、YaCy を使用してローカル ネットワークのインデックスを作成するには、 「最初のステップ」セクションで 3 番目のオプションを選択する必要があります。その後、 Advanced Crawler を使用してイントラネットをクロールできるようになります。

結論 

YaCy でできることは他にもたくさんあります。このプロジェクトは、検索エンジンのすべての機能をカバーするのに十分なドキュメントを提供していません。ただし、このプロジェクトは非常に直感的であり、そのインターフェイスは適切なオプションを切り替えるのに十分なほど冗長です。 

すべてを考慮すると、YaCy は、公平で広告がなく、プライバシーを尊重した匿名の Web 検索エンジンを求めるユーザーにとって最適なオプションの 1 つです。このエンジンは、ユーザーが Web サイト上またはイントラネット内で非公開でコンテンツを検索するのにも使用できます。

最適な Web ブラウザをリストしました