Too many results (non relevant matches)

20 views
Skip to first unread message

David Krmpotic

unread,
Mar 22, 2015, 10:43:08 AM3/22/15
to thinkin...@googlegroups.com
I'm doing this query:

Post.search "socke", {:with=>{:user_id=>1}, :page=>1, :per_page=>10,
:field_weights=>{:text=>1, :tags=>100000},
:ranker=>:wordcount, :select=>"*, weight() * 10 + created_at / 100
 as custom_weight"
, :order=>"custom_weight DESC"}

And first result is post with id 7552, however:

irb(main):005:0> Post.find(7552).text.index('socke')
 
Post Load (1.1ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1  [["id", 7552]]
=> nil
irb
(main):006:0> Post.find(7552).tags.index('socke')
 
Post Load (0.7ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1  [["id", 7552]]
=> nil
irb
(main):007:0> Post.find(7552).text.index('sock')
 
Post Load (0.6ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1  [["id", 7552]]
=> 10251

I don't know why this (and further) result is a match...

I'm experimenting with start search but at the moment it is turned off...

This is the setup of the model:

ThinkingSphinx::Index.define :post, with: :active_record, delta: true do
  indexes
:text
  indexes
:tags

  has
:user_id
  has
:created_at

end

Thank you for any hints...

PS: I'm using TS 3.1.3 and Sphinx 2.2.5

david

David Krmpotic

unread,
Mar 22, 2015, 10:44:05 AM3/22/15
to thinkin...@googlegroups.com
"I'm experimenting with STAR search".... not start search

Pat Allan

unread,
Mar 22, 2015, 6:21:28 PM3/22/15
to thinkin...@googlegroups.com
Hi David

Do you have any settings in config/thinking_sphinx.yml? Particularly the morphology setting can influence matches beyond an ‘exact’ sense.

— 
Pat

--
You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thinking-sphi...@googlegroups.com.
To post to this group, send email to thinkin...@googlegroups.com.
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.

David Krmpotic

unread,
Mar 22, 2015, 6:53:26 PM3/22/15
to thinkin...@googlegroups.com
Hi Pat!

Yes indeed I have, forgot about that... or better said I thought "morphology: stem_en" only deals with plurals...

socke vs. sock is maybe mistaken as a plural form then?

--
You received this message because you are subscribed to a topic in the Google Groups "Thinking Sphinx" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/thinking-sphinx/gG9WWQAMV_E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to thinking-sphi...@googlegroups.com.

David Krmpotic

unread,
Mar 22, 2015, 7:01:46 PM3/22/15
to thinkin...@googlegroups.com
PS: I would need another clarification, I just tested something:

I thought that even if I set 

set_property enable_star: true
set_property min_infix_len: 1

on the model that if I don't do :start => true when searching then it's as if I didn't have these two properties... but that's not true...

for example I search for "gtre" and I get match "gtrereraasd" when I have these two properties in the index... I haven't set :star => true, in fact I have also tried setting :star => false in case true would be a default when enable_start property is set on index...




Pat Allan

unread,
Mar 27, 2015, 7:46:19 PM3/27/15
to thinkin...@googlegroups.com
I would presume the morphology is the cause of the socke vs sock issue (best way to be sure is to disable it and test).

As for the partial matches - I’m not entirely sure what Sphinx’s _correct_ behaviour is here. My understanding is that min_infix_len should mean that gtrereraasd be indexed as g, gt, gtr, gtre, etc… and so the behaviour you’re seeing is appropriate. However, I know that Sphinx is often not reliable in that behaviour, without adding the wildcard stars to a query. In short: not sure how to _stop_ partial matching in your situation.

— 
Pat

David Krmpotic

unread,
Mar 31, 2015, 5:06:39 PM3/31/15
to thinkin...@googlegroups.com
Pat,

Thank you for the explanation! So I guess I cannot use this because I cannot revert to normal behaviour from code... 

looks like once indexed with these attributes, it affects the queries even if no :star => true is used...

david

Pat Allan

unread,
Mar 31, 2015, 8:06:00 PM3/31/15
to thinkin...@googlegroups.com
The only way around this I can think of is to have two different indices for each model, one with infix set to 0, and the other with it set to 1 - of course, that’ll only help if there are specific situations where you only want partial matches, and others where you only want exact matches. It could very likely be overkill.
Reply all
Reply to author
Forward
0 new messages