Reputation: 20415
I have a phrase to be matched against a text column. My phrase has multiple keywords, each associated with a given weight. For example,
Johnson [10] Software [5] Company [2]
I am using PostgreSQL full text search, and may use Thinking-Sphinx or Solr. Is there a function in these 3 options that allows me to search with different weights for each keyword?
Upvotes: 0
Views: 333
Reputation: 396
Perhaps it's more easy to do it during indexation.
Indeed, you know words in your document, you can compute a "factor" during indexation
and so you can use rank_expr to influence ranking by this factor.
Upvotes: 0
Reputation: 3433
I think perhaps you might be trying to assign weight at the wrong point, hence the question?
Your question implies that you can (somehow) assign weight at a query level (which is impossible with Sphinx). I'm not familiar with Solr, but what happens in Solr when a query is "Software Company Johnson", and more importantly, how can you dynamically decide which is a name, which is a category and which is a type of category? Seems much more complicated to me.
Sphinx, which I can speak for, is very good at assigning a weight to various columns on a database, especially with Rails using ThinkingSphinx. More than likely you should have a name, category and type field with this scenario, if not I would suggest you have one. Then you could easily rank weight to name, type and category respectively. This should also be simple to accomplish in Solr.
Upvotes: 0
Reputation: 21091
Sphinx (and therefore Thinking-Sphinx) doesn't have a comparable feature.
But it can be emulated by various means, but to be clear, it can be tricky to setup. If this is the only reason to pick a product don't pick sphinx. But if you have other reasons to pick sphinx, then it could work out for you.
Upvotes: 1
Reputation: 9049
Solr allows you to do this.
Your query would look like this
q=(Johnson)^10 (Software)^5 (Company)^2
Note that the default operator (AND or OR) defined in your schema.xml
comes into play here.
Upvotes: 1