Just to confirm - this data is not in PostgreSQL or MySQL, but only in MongoDB? 
Are you using the standard SQL-backed indices, or the real-time indices?

Although I don’t think it matters too much, because what you’d need is some 
kind of hash/dictionary to provide the different ordering, and Sphinx has no 
such concept. If you had these data points mapped in a separate model instead, 
and then indexed *that* model and called search on that, that could provide 
what you’re after - but whether it’s worth it is your call.

If you were to venture down that path, perhaps with a model named UserItem:

  ThinkingSphinx::Index.define :user_item, :with => :active_record do
    indexes item.name

    has rank, user_id
  end

  UserItem.search(:with => {:user_id => user.id}, :order => ‘rank DESC’)

— 
Pat

On 19 Nov 2013, at 5:37 pm, JSWorld <[email protected]> wrote:

> Hi,
> 
> I have a cache store as follows,
> 
> For every user in the system, his match with every item in the inventory.
> 
> user1_id => {item1_id => 90, item2_id => 85, item3_id => 75}
> user2_id => {item1_id => 70, item2_id => 85, item3_id => 95}
> 
> Currently, the above hash is being computed and stored in MongoDB.
> 
> Requirement: when the user visits the inventory listing page, I want all the 
> items to be listed in order of his match.
> 
> For user_1,
> it should be in the order of item1, item2, item3
> 
> For user_2,
> it should be in the order of item3, item2, item1.
> 
> What is the best way to index this in sphinx, so that i can order it with 
> sphinx something like,
> 
>    Item.search("", :with => {:user_reference => user1_id}, :order => 
> "item_match DESC"
> 
> Thanks,
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to