Sphinx index without errors but it doesn't fetch any instance

Harí Carreras's Avatar

Harí Carreras

15 Sep, 2016 11:56 AM

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. Support Staff 1 Posted by Pat Allan on 15 Sep, 2016 12:02 PM

    Pat Allan's Avatar

    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. 2 Posted by Harí Carreras on 15 Sep, 2016 12:22 PM

    Harí Carreras's Avatar

    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. 3 Posted by Harí Carreras on 15 Sep, 2016 12:23 PM

    Harí Carreras's Avatar

    The error is still the same (in case I was not clear enough :)

  4. Support Staff 4 Posted by Pat Allan on 15 Sep, 2016 12:23 PM

    Pat Allan's Avatar

    It’s normal even if you’re not using deltas - nothing to worry about at all :)

  5. Support Staff 5 Posted by Pat Allan on 15 Sep, 2016 12:24 PM

    Pat Allan's Avatar

    Oh, you’re still not seeing search results?

  6. 6 Posted by Harí Carreras on 15 Sep, 2016 12:28 PM

    Harí Carreras's Avatar

    Unfortunately, not... It was the problem I had before (the empty database was only in the moment I posted this)

  7. Support Staff 7 Posted by Pat Allan on 15 Sep, 2016 12:37 PM

    Pat Allan's Avatar

    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. 8 Posted by Harí Carreras on 15 Sep, 2016 12:45 PM

    Harí Carreras's Avatar

    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. Support Staff 9 Posted by Pat Allan on 15 Sep, 2016 12:48 PM

    Pat Allan's Avatar

    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. 10 Posted by Harí Carreras on 15 Sep, 2016 12:54 PM

    Harí Carreras's Avatar

    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. Support Staff 11 Posted by Pat Allan on 15 Sep, 2016 12:58 PM

    Pat Allan's Avatar

    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. 12 Posted by Harí Carreras on 15 Sep, 2016 01:04 PM

    Harí Carreras's Avatar

    I can't believe this. I was missing an env variable.
    Thanks a lot for your time Pat.

  13. Support Staff 13 Posted by Pat Allan on 15 Sep, 2016 01:09 PM

    Pat Allan's Avatar

    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. 14 Posted by Harí Carreras on 15 Sep, 2016 01:11 PM

    Harí Carreras's Avatar

    Sleep well on Wurundjeri land :)

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac