Search code examples
sphinxthinking-sphinx

How to debug indexed data by thinking sphinx


I'm new with sphinx and I'd like to see what's in technology_core because my query is not returning what should be. Actually is not even querying in the db those two results.

Processing by TechnologiesController#index as JS
  Parameters: {"utf8"=>"✓", "filter"=>{"tech_type"=>["1"], "area_of_interest"=>["4"]}, "query"=>"", "_"=>"1417734808773"}
  Sphinx Query (1.4ms)  SELECT *, groupby() AS sphinx_internal_group, id AS sphinx_document_id, count(DISTINCT sphinx_document_id) AS sphinx_internal_count FROM `technology_core` WHERE `tag_id` IN (1, 4) AND `sphinx_deleted` = 0 GROUP BY `technology_id` HAVING COUNT(*)=2 LIMIT 0, 20
  Sphinx  Found 2 results
  Rendered collection (0.0ms)
  Rendered technologies/index.js.erb (2.7ms)
Completed 200 OK in 15ms (Views: 12.7ms | ActiveRecord: 0.0ms)

I though data were stored into a new db table but there's no a technology_core table created. Then I remembered there's a db/sphinx folder, so I guess the indexed data must be stored in there.
Is there a way to query that technology_core table?


Solution

  • You can connect to Sphinx via the mysql command-line tool:

    mysql --host 127.0.0.1 --port 9306
    

    And then run SphinxQL queries (which is similar but not the same as SQL - the Sphinx Query line in your log is a SphinxQL query). The Sphinx docs cover the syntax pretty well.

    It's worth keeping in mind that SphinxQL queries will return all attribute values (well, unless you only request some attributes in your SELECT clause), but they will not return fields.