🐙
Algoliaを触ったときに調べたことのメモ
Algoliaはフルマネージドな検索サービス
検索用のデータを登録する時の形式
JSONを用意すれば良い、公式に載っている例だとこんな感じ
{
"title": "Blackberry and blueberry pie",
"description": "A delicious pie recipe that combines blueberries and blackberries.",
"image": "https://yourdomain.com/blackberry-blueberry-pie.jpg",
"likes": 1128,
"sales": 284,
"categories": ["pie", "dessert", "sweet"],
"gluten_free": false
}
データのインポート
-
APIもしくはdashboardから登録できる
APIは以下の言語から利用できる。

Indexとは
- データと各種設定(検索条件など)を含むデータセットの単位
- Indexに対してデータを登録、検索条件やソート条件などを設定する
- Indexは複製できる
-
New->Replicaで Index の複製を作成する
-
-
新着順や人気順といった検索結果の取得はそれぞれのソート条件を適用したIndexを用意することで実現できる
検索対象のデータ(属性)を明示的に指定する
Algolia lets you define in which specific attributes to search, using the searchableAttributes parameter. By default, the engine searches within the entire record, but you want to adjust this: this better for performance, and allows you to remove noise.
- デフォルトで全てのデータが検索対象になる、それによってノイズが乗ることもある
-
Configuration->Searchable attributesから検索対象としたいatributeを追加する
検索のソート条件を設定するとき
日付順 といった検索したいときはIndexに対して条件を設定する
-
Configuration->Ranking and sortingにソート条件を設定する
Ranking
Ranking = 検索結果の優先順位付け
日本語を含むデータを検索するときにやること
-
Configuration->LanguageのIndex LanguagesとQuery LanguagesにJapaneseをセットする
その他
-
ISO 8601の日付文字列はAlgoliaではsortできない、代わりにUnixTimeに変換した値を登録しておく
Discussion