Module: MongoSphinx::Indexer

Defined in:
lib/indexer.rb

Overview

Module Indexer contains classes for creating XML input documents for the indexer. Each Sphinx index consists of a single "sphinx:docset" with any number of "sphinx:document" tags.

The XML source can be generated from an array of CouchRest objects or from an array of Hashes containing at least fields "classname" and "_id" as returned by MongoDB view "MongoSphinxIndex/couchrests_by_timestamp".

Sample:

rows = [{ 'name' => 'John', 'phone' => '199 43828',
        'classname' => 'Address', '_id' => 'Address-234164'
      },
      { 'name' => 'Sue', 'mobile' => '828 19439',
        'classname' => 'Address', '_id' => 'Address-422433'
     }
]
puts MongoSphinx::Indexer::XMLDocset.new(rows).to_s

sphinx:docset sphinx:schema <sphinx:attr name="csphinx-class" type="multi"/> <sphinx:field name="classname"/> <sphinx:field name="name"/> <sphinx:field name="phone"/> <sphinx:field name="mobile"/> <sphinx:field name="created_at"/> </sphinx:schema> <sphinx:document id="234164"> 336,623,883,1140 Address <created_at></created_at> </sphinx:document> <sphinx:document id="423423"> 336,623,883,1140 Address <created_at></created_at> </sphinx:document> </sphinx:docset>"

Defined Under Namespace

Classes: XMLDoc, XMLDocset