Have a look at the SQL query generated in your development.sphinx.conf
file, try running that for a specific record, and see if it returns
the data you want. And then to search, you'll need to try:
Item.search "keywords", :with => {:video_or_pictures => 1}
Cheers
--
Pat
On 25/03/2009, at 4:10 PM, Iván Belmonte wrote:
>
> Hello Pat
>
> Yes, the intention is very clear. And i've been trying this way too
> (i'm in spain, and here now it is 6 in the morning, i've been 18 hours
> reading and working on this).
> The fact is that the sql seems not to be working really... how can I
> see the video_or_properties field of a search? (sorry for the mistake,
> it is "Pictures", not "properties")
> I'm trying from the console, this way:
>
> Item.search('somekeyword').each {|p| puts p.video_or_pictures }
>
> But of course "video_or_pictures" is not a valid field. How can I see
> how is my model indexing that sql query?
>
>
> Iván
>
> On Mar 25, 5:39 am, Pat Allan <[email protected]> wrote:
>> Hi Iván
>>
>> Again, a custom attribute is going to be best suited. Maybe something
>> like the following:
>> has "has_video = 1 OR (SELECT COUNT(id) FROM properties WHERE
>> item_id = items.id) > 0",
>> :as => :video_or_properties, :type => :integer
>>
>> I'm making some assumptions about the schema and generated query, but
>> hopefully the intention is clear.
>>
>> Cheers
>>
>> --
>> Pat
>> e: [email protected] || m: +614 1327 3337
>> w:http://freelancing-gods.com|| t: twitter.com/pat
>> discworld:http://ausdwcon.org|| skype: patallan
>>
>> On 25/03/2009, at 3:31 PM, Iván Belmonte wrote:
>>
>>
>>
>>> Hello James
>>
>>> Yes I see... Well, I knew these limitations, just wanted to make
>>> sure...
>>
>>> And how can I say "different than"?
>>> Because i'm thinking about something like:
>>
>>> Item.search('(@property_ids !0 | @has_video 1)', :match_mode
>>> => :extended)
>>
>>> Iván
>>
>>> On Mar 25, 5:13 am, James Healy <[email protected]> wrote:
>>>> Hi Ivan,
>>
>>>> Have a read of the following thread, it should answer your
>>>> questions:
>>
>>>> http://groups.google.com/group/thinking-sphinx/browse_thread/
>>>> thread/
>>>> c...
>>
>>>> Essentially, you can use OR when searching indexed text fields, but
>>>> not
>>>> attributes.
>>
>>>> You might also want to read the documentation in
>>>> lib/thinking_sphinx/index/builder.rb, it covers some of the
>>>> differences
>>>> and limitations of fields (indexes ...) and attributes (has ...).
>>
>>>> James
>>
>>>> Iván Belmonte wrote:
>>
>>>>> Well, another solution is applying OR to conditions, this way:
>>
>>>>> in model, as normally:
>>
>>>>> ------------
>>>>> define_index so
>>>>> [...]
>>>>> indexes :has_video
>>>>> has pictures(id), :as => :picture_ids
>>>>> end
>>>>> ------------
>>
>>>>> Then, in the controller;
>>
>>>>> Item.search(:conditions => { :picture_ids => 1..1000
>>>>> | :has_video =>
>>>>> 1 })
>>
>>>>> each condition alone works great. What i'd need is the syntax for
>>>>> "OR'ing" them
>>
>>>>> Iván
>>
>>>>> On Mar 25, 4:39 am, Iván Belmonte <[email protected]> wrote:
>>>>>> Trying to index this way:
>>
>>>>>> indexes pictures.size, :as => :num_pictures
>>
>>>>>> But still not working... i'm desperate :-(
>>
>>>>>> Iván
>>
>>>>>> On Mar 25, 2:38 am, Iván Belmonte <[email protected]> wrote:
>>
>>>>>>> I see that items not having associated pictures don't have the
>>>>>>> field
>>>>>>> "picture_ids", so maybe the easiest way was asking sphinx for
>>>>>>> that
>>>>>>> field.... something like:
>>
>>>>>>> Item.search(:conditions => { :picture_ids => !nil })
>>
>>>>>>> or something similar... does it exist any syntax for asking
>>>>>>> this?
>>
>>>>>>> Thanks again,
>>
>>>>>>> Iván
>>
>>>>>>> On Mar 25, 1:47 am, Iván Belmonte <[email protected]> wrote:
>>
>>>>>>>> Helllo there,
>>
>>>>>>>> I have a model like this:
>>
>>>>>>>> -------------
>>>>>>>> define_index do
>>>>>>>> indexes description
>>>>>>>> indexes amount
>>>>>>>> [...]
>>>>>>>> indexes has_video <----- this field is bool
>>>>>>>> indexes pictures(:id), :as => :picture_ids
>>>>>>>> [...]
>>>>>>>> end
>>>>>>>> --------------
>>
>>>>>>>> Then what i need to search is something like this:
>>
>>>>>>>> --------------
>>>>>>>> Model.search("some keywords" (@has_video "1" | @picture_ids
>>>>>>>> "*")
>>>>>>>> --------------
>>
>>>>>>>> I mean, I need to match:
>>>>>>>> - "some keywords" AND
>>>>>>>> - "has_video" is set to "1" _OR_ Model has one or more
>>>>>>>> Pictures
>>>>>>>> associated.
>>
>>>>>>>> I didn't find any documentation about the second part... how
>>>>>>>> can I do
>>>>>>>> this?
>>
>>>>>>>> Thanks in advance!
>>
>>>>>>>> Ivan
>>
>>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---