I have an app using Flying Sphinx on Heroku. Locally, everything works fine. However, when I deploy to production, it cannot fetch any instance.
I've added the Flying Sphinx add on and run heroku run rake fs:index fs:configure with not results
When I check in the dashboard it gives the feeling that everything is alright.
The app is called on Heroku staging-sennheiser-h-c
Please, let me know which info could I provide to make it easier to debug.
Thanks in advance.
#1 Posted by Pat Allan Support staff on 15 Sep, 2016 12:02 PM
Hi Harí
It looks like there are no Connector, Headset or Device objects in your database - at least, that’s what the output of the fs:index task is saying. Is that correct?
Cheers
—
Pat
#2 Posted by Harí Carreras on 15 Sep, 2016 12:22 PM
Sorry, it must have been because of a new deploy.
The database now contains instances of three of them. However when indexing or rebuilding it says:
skipping non-plain index 'connector'...
skipping non-plain index 'device'...
skipping non-plain index 'headset'...
I've researched and I saw it's normal if I'm using delta indexes.
#3 Posted by Harí Carreras on 15 Sep, 2016 12:23 PM
The error is still the same (in case I was not clear enough :)
#4 Posted by Pat Allan Support staff on 15 Sep, 2016 12:23 PM
It’s normal even if you’re not using deltas - nothing to worry about at all :)
#5 Posted by Pat Allan Support staff on 15 Sep, 2016 12:24 PM
Oh, you’re still not seeing search results?
#6 Posted by Harí Carreras on 15 Sep, 2016 12:28 PM
Unfortunately, not... It was the problem I had before (the empty database was only in the moment I posted this)
#7 Posted by Pat Allan Support staff on 15 Sep, 2016 12:37 PM
Hmm. There’s definitely data stored in your Sphinx indices. Can you share the Ruby code of the Thinking Sphinx search query you’re running?
#8 Posted by Harí Carreras on 15 Sep, 2016 12:45 PM
Hi Pat,
Thanks for answering.
The code is definitely OK since it works in both development and tests.
The search would be like:
def fetch_results
Device.search(
ThinkingSphinx::Query.escape(query),
page: page,
per_page: per,
include: [
:connectors,
:manufacturer
],
with: {
sphinx_internal_id: Device.visible.pluck(:id)
}
)
end
And in my controller I call it:
@devices = DeviceFinder.new(params: { q: params[:term], per: 10_000 }).result
This calls fetch_results
It's running on Rails 3. I've just read your article that for Rails 3 I should use 'flying-sphinx', '0.7.0' and I'm running 1.2.0.
I'm going to try that :)
#9 Posted by Pat Allan Support staff on 15 Sep, 2016 12:48 PM
1.2.0 should be okay with Rails 3 - certainly, I can’t spot any issues that are related to the flying-sphinx gem.
Can you confirm that `Device.visible.pluck(:id)` returns the ids you’re expecting it to? And what query values are you testing this with?
—
Pat
#10 Posted by Harí Carreras on 15 Sep, 2016 12:54 PM
I can confirm that Device.visible.pluck(:id) returns the expected values (around 9485)
I've tried with empty values (in development it returns them correctly) and with some queries like "cisco".
#11 Posted by Pat Allan Support staff on 15 Sep, 2016 12:58 PM
Hmm. I’m running queries directly on your Sphinx daemon and getting results. For example, searching for cisco (without the filter) returns 87 matches (e.g. SELECT * FROM device_core WHERE MATCH('cisco') LIMIT 1000;)
Can you check in your Rails console that searches without the filter are returning the expected results for you?
#12 Posted by Harí Carreras on 15 Sep, 2016 01:04 PM
I can't believe this. I was missing an env variable.
Thanks a lot for your time Pat.
#13 Posted by Pat Allan Support staff on 15 Sep, 2016 01:09 PM
No worries, great to hear you’ve got it working now :)
Any further issues, do let me know! Though it’s just gone 11pm here, so I probably won’t be so prompt to reply in the next several hours :)
#14 Posted by Harí Carreras on 15 Sep, 2016 01:11 PM
Sleep well on Wurundjeri land :)