Sunday, February 13, 2011

How do I retreive relevance value for ThinkingSphinx search results?

Is there any way to retrieve relevance values with results with the array returned by ThinkingSphinx? Percentages, points or whatever, just something I can work with?

  • Yep - you can iterate over the result set, and retrieve the weight for each:

    results = ThinkingSphinx::Search.search(params[:q])
    results.each_with_weighting do |result, weight|
      puts "#{result.name} #{weight}"
    end
    
    From Mr. Matt

0 comments:

Post a Comment