Constant weighting

8 views
Skip to first unread message

Shirley Thompson

unread,
Mar 28, 2025, 7:34:22 PMMar 28
to Thinking Sphinx
Hi, 

I'm using the global search functionality for two models with the classes option: 

ThinkingSphinx
.search_for_ids(
classes: [Folder, Project],
conditions: { name: Riddle::Query.escape(search) },
order: 'w DESC',
select: '*, weight() AS w',
star: true
)

However, when I inspect the weight for each result by doing .pluck('sphinx_internal_class', 'name_sort', 'w'), it's not quite what I'm expecting because they seem to be constant for each classes - the search value was "test":

[["Folder", "tEST", 1630],
 ["Folder", "TEST!", 1630],
 ["Folder", "TEST!!", 1630],
 ["Folder", "testsssss", 1630],
 ["Folder", "testsdafdsfdsfs", 1630],
 ["Folder", "testshirley", 1630],
 ["Folder", "testa", 1630],
 ["Project", "Test Project", 1563],
 ["Project", "TEST", 1563],
 ["Project", "test", 1563],
 ["Project", "TEST!", 1563],
 ["Project", "TEST!", 1563],
 ["Project", "tracking test", 1563],
 ["Project", "TEST", 1563],
 ["Project", "test", 1563],
 ["Project", "test", 1563],
 ["Project", "Duplicate of TEST!", 1563],
 ["Project", "test", 1563],
 ["Project", "test2", 1563],
 ["Project", "test3333", 1563]] 

I also tested this with one class instead of two or even using the single model syntax: Folder.search_for_ids but the weight is the same as above. Was expecting the weight to differ depending on the name.

Thank you in advance!

Pat Allan

unread,
May 22, 2025, 6:28:16 AMMay 22
to thinkin...@googlegroups.com
Hi Shirley,

Firstly, I’m sorry for not responding sooner. I’d say that this Google Group doesn’t get much traffic these days - but I’m also slack at responding to Github Issues as well. 😓

And also, I’m not sure if I have a particularly useful answer for you. Essentially, I think Sphinx is saying “all of these names have ’test’ within them, so they all have the same score”. The non-matching parts of the name likely don’t factor into things at all. One path to investigate could be to try different ranking algorithms and see if any give you a more useful variety of weights:

Others have asked about weighting exact matches over partial matches, but I don’t feel there’s an easy solution on that front.

Granted, it’s been a while, so maybe things have changed with Sphinx and/or Manticore that could provide a better matching approach - a lot of TS was written with Sphinx v2.2.11 in mind, and that was released in 2016.

Again, apologies for the delay.

— 
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 view this discussion visit https://groups.google.com/d/msgid/thinking-sphinx/a1636dcd-c494-40b9-9de7-cf13cad22f2dn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages