Search code examples
ruby-on-rails-3full-text-searchsphinxthinking-sphinx

Does Sphinx provide the capability to extract indexed information rather than hitting the database?


On a successful search will one be able to access the sphinx indexed data instead of hitting the database.

Thinking Sphinx provides the a method to search and retrieve only the document ids through ThinkingSphinx.search_by_ids. Does it provide an API to retrieve only indexed data without hitting the database?


Solution

  • Not exactly all the indexed fields but you can take advantages of sql_attr_string

    From the docs :

    "String attributes can store arbitrary strings attached to every document. There's a fixed size limit of 4 MB per value.

    Note that attributes declared using sql_attr_string will not be full-text indexed; you can use sql_field_string directive for that."

    Hope this will help !


    @Phoenix:

    You can't use indexer as an alternative to database because original contents of the fields are not stored in the Sphinx index.

    From the docs:

    "Note that the original contents of the fields are not stored in the Sphinx index. The text that you send to Sphinx gets processed, and a full-text index (a special data structure that enables quick searches for a keyword) gets built from that text. But the original text contents are then simply discarded. Sphinx assumes that you store those contents elsewhere anyway."

    You can refer doc for more details: