thank you pat, I will try it out shortly. My git installation is getting into issues one after another. Any plans to release it as a gem ?
tx madhu On Aug 27, 7:37 pm, Pat Allan <[email protected]> wrote: > Right, obviously my implementation was not perfect. > > The reason for the array is because when I've been using it for facets, I'm > looping over each facet to search for. But as we've found out, that's not a > good fit in every situation. So I've just pushed a commit that improves > things - you may want to pull down the source, either as a plugin, or to run > 'rake build' to build a new gem locally. > > http://github.com/freelancing-god/thinking-sphinx/commit/2f82bce33472... > > So now, you should be able to do this: > > searches = ThinkingSphinx::Search.bundle_searches do |sphinx| > sphinx.search 'restaurants' > sphinx.search 'automobile' > end > > It's probably not going to work with Model.search calls - but as a > work-around for that, use the :classes option: > > searches = ThinkingSphinx::Search.bundle_searches do |sphinx| > sphinx.search 'restaurants', :classes => [Model] > sphinx.search 'automobile', :classes => [Model] > end > > Cheers > > -- > Pat > > On 28/08/2010, at 3:43 AM, madhu wrote: > > > dear pat, > > > I just tried the code with a dummy array, but i have noticed only the > > last search query is getting executed and the return result set have > > always one array element > > > TS version have : thinking-sphinx-1.3.19 > > > for example : > > > my_araay = ["dummy_one"] > > results = ThinkingSphinx::Search.bundle_searches(myarr) do |sphinx, > > item_in_array| > > mymodel.search"restaurants" > > mymodel.search"automobile" > > end > > > The end results is a something like this [[#<Product id: > > 121,.....>,#<Product id: 122,.....>,#<Product id: 123,.....>.....]] > > > The result contains search results for "automobile" (for this example) > > and there is always one one result set in the array. i was expecting > > something like this: > > [ [#<Product id: 121,.....>,#<Product id: 122,.....>,#<Product id: > > 123,.....>.....], > > [#<Product id: 124,.....>,#<Product id: 125,.....>,#<Product id: > > 126,.....>.....] > > ] > > > tx > > madhu > > > On Aug 27, 10:59 am, madhu <[email protected]> wrote: > >> sorry about the incomplete post before let me repeat my post : > > >> hello pat, > > >> Thank you for the swift reply. I a little confused about what should > >> contain in the array ? Let me try with an example. > >> mymodel = MyModel.new > >> my_arr = [mymodel] > > >> ThinkingSphinx::Search.bundle_searches(my_arr) do | > >> model_obj,what_is_this_element_for| > >> model_obj.search "extended search query one",:index => > >> "index_name",:matchmode =>:extended > >> model_obj.search "extended search query two",:index => > >> "index_name",:matchmode =>:extended > >> end > > >> Is it some thing similar to the syntax above ? if so what is the > >> second element for "what_is_this_element_for" in the array ? what > >> should i fill that with ? and where is it used ? Do you think this is > >> stable enough to go production ? > > >> tx > >> madhu > > >> On Aug 27, 10:51 am, madhu <[email protected]> wrote: > > >>> hello pat, > > >>> Thank you for the swift reply. I a little confused about what should > >>> contain in the array ? Let me try with an example. > >>> mymodel = MyMode.new > >>> my_arr = > > >>> On Aug 27, 8:39 am, Pat Allan <[email protected]> wrote: > > >>>> I've actually just added this recently - so make sure you're using the > >>>> latest gem (or the latest source as a plugin). > > >>>> Keep in mind I've built this functionality to help speed up facet > >>>> queries, so not sure how well it fits general use, but hopefully it does > >>>> the job: > > >>>> ThinkingSphinx::Search.bundle_searches(array) do |sphinx, item_in_array| > >>>> sphinx.search "condition_one condition_two" > >>>> sphinx.search "condition_two" > >>>> end > > >>>> That will return an array of search results... now, I can see that the > >>>> array provided as an argument (and the subsequent yielding of each item) > >>>> only works if you're naturally creating a set of queries from some kind > >>>> of collection. So at this point, you *need* an array with something in > >>>> it - otherwise, there's nothing to loop over, and your inner block won't > >>>> run. > > >>>> You *should* be able to call #search on the sphinx object as many times > >>>> as you like, and it will queue up each search (ie: you don't need to > >>>> call it just once per yield). > > >>>> Anyway, see how you go, and let me know if you get stuck :) > > >>>> -- > >>>> Pat > > >>>> On 27/08/2010, at 2:52 PM, madhu wrote: > > >>>>> dear pat, > > >>>>> Is there a way to make batch query in TS ? For example: > > >>>>> 1) my first query is something like this "condition_one condition_two" > >>>>> 2) my second query is something like this "condition_one > >>>>> condition_three" > > >>>>> Please note the "condition_one" remains the same in both the places. > >>>>> These queries are very complex extended queries. > > >>>>> When i contacted the excellent sphinx support team about performance > >>>>> improvement, they suggested me to run it in batch queries. The PHP > >>>>> code is something like this : > > >>>>> $cl->AddQuery(query1); > >>>>> $cl->AddQuery(query2); > >>>>> $res = $cl->RunQueries (); > > >>>>> Is there such an option available in TS ? > > >>>>> tx > >>>>> madhu > > >>>>> -- > >>>>> 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.
