Hi Pat,

Thanks for your reply. This is what I have done.

word_count is the number of words in a document excluding stopwords
generated by a mysql function.

with_filter = "*, IF( @weight >=  word_count,1,0) AS filter"

 sphinx_result = ProductsFilterCollections.search('"heat and dust
hachette book publishing"/1', :match_mode => :extended, :rank_mode
=> :wordcount, :sphinx_select => with_filter, :with => {'filter' =>
1})

 sphinx_result.results value is
{:matches=>[{:doc=>139, :weight=>2, :index=>0, 
:attributes=>{"sphinx_internal_id"=>46,
"sphinx_deleted"=>0, "class_crc"=>2200458759,
"sphinx_internal_class"=>"ProductsFilterCollections",
"sub_category_id"=>1, "word_count"=>2, "filter"=>1}},
{:doc=>232, :weight=>2, :index=>1, :attributes=>{"sphinx_internal_id"=>77,
"sphinx_deleted"=>0, "class_crc"=>2200458759,
"sphinx_internal_class"=>"ProductsFilterCollections",
"sub_category_id"=>1, "word_count"=>2,
"filter"=>1}}], :fields=>["filter_key"], :attributes=>{"sphinx_internal_id"=>1,
"sphinx_deleted"=>1, "class_crc"=>1, "sphinx_internal_class"=>7,
"sub_category_id"=>1, "word_count"=>1,
"filter"=>1}, :attribute_names=>["sphinx_internal_id",
"sphinx_deleted", "class_crc", "sphinx_internal_class",
"sub_category_id", "word_count",
"filter"], :words=>{"heat"=>{:docs=>2, :hits=>2},
"dust"=>{:docs=>2, :hits=>2},
"hachette"=>{:docs=>0, :hits=>0}}, :status=>0, :total=>2, :total_found=>2, 
:time=>0.001}

 @unmatched_keywords = [ ]

 sphinx_result.results[:words].keys.each do |i|
    if sphinx_result.results[:words][i][:hits] == 0
      @unmatched_keywords << i
    end
 end

Now the value of @unmatched_keywords is ["hachette", "book",
"publishing"].


I get what I want.

Kindly validate.

Thanks,
Senthil.






-- 
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.

Reply via email to