Rails 4.2 install : reindex is nil while model does have entries

Hello,

I am installing algolia in my 4.2 rails app. To begin my implementation, I want to search into recipes. I did follow the instruction and added to my Recipe model :

include AlgoliaSearch

algoliasearch do
attribute :title, :description
searchableAttributes [‘title’]
end

I just wanted to test at that stage the indexation so I did Rails c

Recipe.reindex
Recipe Load (0.8ms) SELECT recipes.* FROM recipes ORDER BY recipes.id ASC LIMIT 1000
=> nil

I am getting nil while I do have several recipe in my postgress db:

Recipe.first
Recipe Load (0.4ms) SELECT recipes.* FROM recipes ORDER BY recipes.id ASC LIMIT 1
=> #<Recipe:0x007ffa6bf77c00
id: 1,
user_id: 879,
title: “Tomate moz”,
description: “Superbe recette de Aldo”,
instructions: nil,
preparation_time: 5,
cooking_time: 0,
steps: “1. laver les tomates\r\n2. couper les tomates\r\n3. les disposer en tranche avec la moz\r\nSel, poivre\r\nArrosé d’huile”,
rating: nil,
created_at: Fri, 18 Aug 2017 09:38:56 UTC +00:00,
updated_at: Fri, 18 Aug 2017 09:38:56 UTC +00:00>

What am I missing ?

Hi @michael4,

Disclaimer: I’m not a Ruby guy

You shouldn’t expect the reindex method to return anything.
It will simply loop over all your records and push them to Algolia.

Can you check in your Algolia dashboard to ensure the records are properly pushed?

Hello,
Thank you, effectively I saw the model had been indexed to Algolia, so I am all fine.

Best regards

1 Like