0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

meilisearchで社内情報を検索できるツールを作る

0
Posted at

はじめに

google検索がAIを活用して自然言語で検索できるようになりましたが、その反動でai機能をオフにできるduckduckgoの利用率が上がってるらしいです。
そんなニュースを聞いてふと「検索エンジンってどうなってるんだろう」と軽く調べたところmeilisearchというものに出会いました。

Meili Searchは高速な全文検索サーバです。
このサーバに社内で管理しているチケットや記事のデータを流し込んでおくことで、社内情報を素早く検索することができます。
弊社ではチケット管理にredmine、ドキュメント管理にkibelaを利用しています。これらのサービスはapiで情報を取り出すことができるのでapiで取得した情報をmeilisearchに投入します。

実装してみる

開発ドキュメントはここ

各開発言語についてSDKが準備されているので、それを利用するのが良いでしょう。
今回はrubyを使った例について説明します。

Railsアプリケーションで実装している場合は、以下のようにしてGemfileに追加してください

gem 'meilisearch'

イベント内にあるように以下のようにして、meilisearchにドキュメントを追加することができます。
https://www.meilisearch.com/docs/reference/api/documents/add-or-replace-documents
ここに記されているように、追加するドキュメントの形式はどのような形式でも良いようです。

movies = [
  { id: 1, title: 'The Matrix', genres: ['Action', 'Sci-Fi'], year: 1999 },
  { id: 2, title: 'Inception', genres: ['Action', 'Thriller'], year: 2010 },
  { id: 3, title: 'Interstellar', genres: ['Drama', 'Sci-Fi'], year: 2014 }
]

# Add documents to the 'movies' index
task = client.index('movies').add_documents(movies)

# Wait for indexing to complete
client.wait_for_task(task['taskUid'])

ドキュメントの検索は以下のようにして実装することができます。

results = client.index('movies').search('matrix')

puts results['hits']
# [{"id"=>1, "title"=>"The Matrix", "genres"=>["Action", "Sci-Fi"], "year"=>1999}]

これを利用することで、例えばredmineのチケットをmarkdownのドキュメントをクーロンで定期的にmeilisearchのドキュメント追加しておくことで、高速な社内ドキュメント検索ツールを作成することができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?