You can access all attribute values within each object like so:

  image.sphinx_attributes['superkarma']

-- 
Pat

On 06/08/2011, at 1:58 AM, gerberdata wrote:

> Thank Pat would I be able to see the superkarma value on the returnset
> 
> #<Image id: 20, name: "Ford", description: "", photo_file_name:
> "Ford.JPG",
> photo_updated_at: "2009-12-29 05:52:50", photo_file_size: 78823,
> image_holder_id: 2, image_holder_type: "Sport", source: "",
> source_url: "", created_at: "2009-12-29 05:52:51",
> updated_at: "2009-12-29 05:52:51", creator_id: 9, updater_id: 9,
> deleter_id: nil, is_deleted: false, hit_count: 18, delta: false>,
> 
> I don't see the superkarma value or the hit_count numbervalue changed
> this is how I ran it
> Image.search "",:sphinx_select => '*, hit_count + 1000 AS superkarma'
> 
> 
> On Aug 4, 6:59 pm, Pat Allan <[email protected]> wrote:
>> Hi Dave
>> 
>> The '@' prefix is only used for internal attributes (@geodist, 
>> @weight/@relevance) - so give it a shot as just hit_count, not @hit_count.
>> 
>> --
>> Pat
>> 
>> On 05/08/2011, at 2:13 AM, gerberdata wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> Hi Pat,
>>>       Thanks for the reply first I would like to know more about what
>>> you were thinking about with "generate an attribute on the fly"
>>> I played around with the :sphinx_select syntax and got some errors
>>> with it.  Can you tell me what I am doing wrong here.  As an
>>> example I tried
>> 
>>> Car.search "",:sphinx_select => '*, @hit_count + 10000 AS
>>> superkarma'
>> 
>>> unknown identifier '@hit_count' (not an attribute, not a function)
>> 
>>> from the documentation it looks like I need to make hit_count an
>>> attribute on the model which I did but
>>> it still doesn't work.
>> 
>>> do you know what am I doing incorrectly here?
>> 
>>> On Aug 3, 5:17 pm, Pat Allan <[email protected]> wrote:
>>>> Hi Dave
>> 
>>>> I'm afraid field_weights won't work, because firstly, you'll need to be 
>>>> sorting by relevance, and secondly, created_at is an attribute, not a 
>>>> field.
>> 
>>>> I'm not sure of the finer points, but perhaps you can use Sphinx's select 
>>>> query to generate an attribute on the fly, which is essentially a simple 
>>>> integer value to set priorities, and sort by that and *then* 
>>>> created_at?http://sphinxsearch.com/docs/manual-2.0.1.html#api-func-setselect
>> 
>>>> Use :sphinx_select to pass the string through in your search query - and 
>>>> keep in mind, you'll need to refer to existing attributes, but I don't 
>>>> think you can use field values.
>> 
>>>> --
>>>> Pat
>> 
>>>> On 04/08/2011, at 8:43 AM, gerberdata wrote:
>> 
>>>>> Maybe I could also use field weights
>> 
>>>>> set_property :field_weights => {
>>>>>  :holder_type => 10,
>>>>>  :created_at    => 6,
>>>>> }
>> 
>>>>> what would happen to the result if I added weights?
>> 
>>>>> On Aug 3, 12:58 pm, gerberdata <[email protected]> wrote:
>>>>>> Maybe using group_by will work except I am trying to figure out how to
>>>>>> use the
>> 
>>>>>> :group_function :attr
>> 
>>>>>> can this be grouped on a field instead of an attribute?
>> 
>>>>>> the field I need to group on is holder_type
>>>>>> indexes :image_holder_type, :as => :holder_type
>> 
>>>>>> On Aug 2, 11:26 pm, gerberdata <[email protected]> wrote:
>> 
>>>>>>> Pat,
>> 
>>>>>>> here is the gist of what we are doing
>> 
>>>>>>> if image_holder == "Car"
>>>>>>>   tagger_key = [@image_holder.to_search_key,
>>>>>>> @image_holder.dealerships.collect{|dealership|
>>>>>>> dealership.to_search_key}].flatten.join(" | ")
>>>>>>> end
>>>>>>> conditions = "@tagger_keys (#{tagger_key})"
>>>>>>> query_text = @s_query.blank? ? conditions : @s_query + "* & " +
>>>>>>> conditions
>> 
>>>>>>> then we run the search
>> 
>>>>>>> images = Image.search query_text || "", :include=>[:tags],  :per_page
>>>>>>> => @image_holder.blank? ? $LIST_PER_PAGE :
>>>>>>> @per_page, :page=>@current_page, :order=>"tagger_keys asc, created_at
>>>>>>> DESC", :match_mode => :boolean
>> 
>>>>>>> this produces a result where we get the records in the correct order
>>>>>>> according to our tagger_keys, but the created_at is not showing
>>>>>>> in the proper descending order. So the created_at DESC does not seem
>>>>>>> to be run properly we need to show the most recent images within each
>>>>>>> tagger_keys
>> 
>>>>>>> in our images model we have the tagger_keys sortable
>>>>>>> indexes tags.tagger_key, :as => :tagger_keys, :sortable => true
>> 
>>>>>>> So basically the date order is what is not working in this current
>>>>>>> form.
>> 
>>>>>>> Thanks for the help
>> 
>>>>>>> Dave
>> 
>>>>>>> On Aug 2, 8:22 pm, gerberdata <[email protected]> wrote:
>> 
>>>>>>>>  we get all the image keys for a car first, then we get all the keys
>>>>>>>> for a car.dealers and then we join all
>>>>>>>> those keys together and pass it into search with the or expression.
>>>>>>>> We need to prioritize this result firstly by the car and then the most
>>>>>>>> recent car image,  and then by the car dealer and the most recent
>>>>>>>> image of the car dealer.  Right now the result returns only in
>>>>>>>> the date order.
>> 
>>>>>>>> Is this possible?
>> 
>>>>>>>> On Aug 2, 7:38 pm, Pat Allan <[email protected]> wrote:
>> 
>>>>>>>>> Not sure if I quite understand this - do you want to prioritise a 
>>>>>>>>> specific image_holder_id, and then sort firstly within that id by 
>>>>>>>>> date, and then all other results by date?
>> 
>>>>>>>>> --
>>>>>>>>> Pat
>> 
>>>>>>>>> On 03/08/2011, at 12:04 PM, gerberdata wrote:
>> 
>>>>>>>>>> Looking to get some help and ideas for this issue I have here.  Maybe
>>>>>>>>>> one of the excellent minds on
>>>>>>>>>> this board can help
>> 
>>>>>>>>>> @images = Image.search
>>>>>>>>>> key1,key2,key3 ,   :per_page=>1, :page=>pos, :order=>"created_at
>>>>>>>>>> DESC", :match_mode => :boolean
>> 
>>>>>>>>>> I need to be able to sort as follows
>> 
>>>>>>>>>> 1. keep the created_at DESC as the first sort
>>>>>>>>>> 2. have an additional sort which sorts on the image_holder_id
>> 
>>>>>>>>>> here is the indexing for image_holder_id
>>>>>>>>>> has :image_holder_id, :as => :holder_id
>> 
>>>>>>>>>> so can picture it this way I have a url for one particular cars
>>>>>>>>>> profile and
>>>>>>>>>> I want to show the images of the car first and then the related
>>>>>>>>>> things to car
>> 
>>>>>>>>>> imageofcar1  created today image_holder:current_car
>>>>>>>>>> imageofcar2  created today image_holder:current_car
>>>>>>>>>> imageofcardealer created today image_holder:car_dealer
>>>>>>>>>> imageofcardealer created today image_holder:car_dealer
>>>>>>>>>> imageofcardealer created yesterday image_holder:car_dealer
>>>>>>>>>> imageofcardealer created yesterday image_holder:car_dealer
>> 
>>>>>>>>>> But my current result is this
>>>>>>>>>> imageofcardealer created today image_holder:car_dealer
>>>>>>>>>> imageofcar1  created today image_holder:current_car
>>>>>>>>>> imageofcardealer created today image_holder:car_dealer
>>>>>>>>>> imageofcar2  created today image_holder:current_car
>>>>>>>>>> imageofcardealer created yesterday image_holder:car_dealer
>>>>>>>>>> imageofcardealer created yesterday image_holder:car_dealer
>> 
>>>>>>>>>> this is wrong because I want to show the imagesofcars first then the
>>>>>>>>>> images of cardealers
>> 
>>>>>>>>>> --
>>>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>>>> Groups "Thinking Sphinx" group.
>>>>>>>>>> To post to this group, send email to 
>>>>>>>>>> [email protected].
>>>>>>>>>> To unsubscribe from this group, send email to 
>>>>>>>>>> [email protected].
>>>>>>>>>> For more options, visit this group 
>>>>>>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>> 
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Thinking Sphinx" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to 
>>>>> [email protected].
>>>>> For more options, visit this group 
>>>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Thinking Sphinx" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to