Skip to content
  • azul's avatar
    Upgrade Thinking Sphinx to 3.1.4 - requires sphinx > 2.1.4 · c9b6d0c8
    azul authored
    There we go. Finally the upgrade of thinking sphinx.
    
    In order to deploy this we will need a fairly recent version of Sphinx.
    I suggest we jump right to the latest of the 2.2 series.
    
    Thinking Sphinx now uses app/indices for its index definitions.
    It also requires some options to search to be hashes.
    
    There's a nice upgrade documentation that i followed:
    http://freelancing-gods.com/thinking-sphinx/upgrading.html
    Most of it does not affect us though.
    
    The main change was to use with_all instead of with in sphinx queries.
    This way we can still have multiple constraints on the same field:
    So for example to search '(1 OR 2 OR 3) AND (4 OR 5 OR 6)'
    
    [Here](http://freelancing-gods.com/thinking-sphinx/searching.html#filters)'s
    the new way of doing this:
    
    > You can also perform combination AND and OR matches with
    > :with_all using nested arrays:
    >
    > ```ruby
    > # All pancackes belonging to tag 3 and belonging to one of tag 1 or tag 2
    > Article.search 'pancakes',
    >   :with_all => {:tag_ids => [[1,2], 3]}
    > ```
    
    So now we build @with in the sphinx query to be an array of arrays that
    can be feed into with_all.
    
    Before we used to send an array to thinking sphinx instead of a hash.
    
    ```ruby
    Page.search 'text', :with =>
      [[:access_ids, '1 2 3'], [:access_ids, '4 5 6']]
    ```
    c9b6d0c8