What if I log the quries into the database everytime a person searches for something?
like everytime the search a word I tried to find the word in the database then if the db can't find it creates it and if it finds it, it increments the value up by one? -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Pat Allan Sent: Tuesday, January 27, 2009 1:28 PM To: [email protected] Subject: [ts] Re: How do i log the search results of thinking sphinx You could use alias_method to track queries yourself... it's not quite so elegant, though, and you'd need to hook the current user in somehow. It's definitely not something built into Thinking Sphinx, but I'm sure it's possible. I'm not sure of the best way to alias class-level methods - the following code is for instance-level methods, but ThinkingSphinx::Search.search is class-level, so this WILL NOT work. It may provide some inspiration though. module SphinxLogger def self.included(base) base.class_eval do alias_method :search_without_logging, :search def search(*args) # Pull options out of the array options = args.extract_options! query = args.join(" ") # log your query here... # Push options back into the array args << options # Run the actual query in the original code search_without_logging(*args) end end end end ThinkingSphinx::Search.send(:include, SphinxLogger) -- Pat On 22/01/2009, at 11:11 PM, tyliong wrote: > > Hi, > > is it possible for TS to log the search query of every user in a > database and update the number of times the search term was used by > that particular user or any user? > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
