Prosto Trader
Prosto Trader

Reputation: 3527

Filter unneccessary words when doing full text search in PostgreSQL

I've created full text search in postgreSQL based on this wonderfull article.

It works good enough, but thing should be fixed.

Say I have blog post in my DB with text: "All kittens go to heaven"

If user searches "All kittens go to heaven, may be..." the DB will return nothing, because words may be are not found.

I can post my sql query but it's pretty much the same as described in article. Is there way to show found articles which have most of searched words?

Upvotes: 2

Views: 179

Answers (1)

Neil McGuigan
Neil McGuigan

Reputation: 48256

This is a fundamental problem with PostgreSQL's Text Search.

You could try to pre-parse the query, and strip out any terms that aren't in the "corpus" of terms of all your documents, but that doesn't really solve your problem.

You could try changing your query to 'or' all the terms, but this could have performance problems.

The best bet would be to try the smlar extension (written by the Text Search authors), which can use cosine/tfidf weighting. This means that the query can have terms that aren't in the document and still match.

Upvotes: 2

Related Questions