Hi Ivan, Have a read of the following thread, it should answer your questions:
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/c481d56f7098437a/f2adc1f5feaa6151 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 -~----------~----~----~----~------~----~------~--~---
