Searching a DB index.. possible?
I am trying to figure out how I can introduce full text search "tips"...
tips meaning, like if you start typing Mer ..
then a box with a couple of words underneath comes up, with *Mercedes,
Mercury *and so on :P
I am thinking that the word suggestions needs to come from the already
existing tsearch2 index.
Words that are frequent in the index could be ranked higher as a search tip.
Is there a way to query the actual existing index?
How else could one approach this? There are many sites that uses this, so
perhaps there is an easier way I haven't thought of yet.
Thank you / Moe
Bump
On Fri, Feb 5, 2010 at 5:48 PM, Moe <mohamed5432154321@gmail.com> wrote:
Show quoted text
I am trying to figure out how I can introduce full text search "tips"...
tips meaning, like if you start typing Mer ..
then a box with a couple of words underneath comes up, with *Mercedes,
Mercury *and so on :PI am thinking that the word suggestions needs to come from the already
existing tsearch2 index.
Words that are frequent in the index could be ranked higher as a search
tip.Is there a way to query the actual existing index?
How else could one approach this? There are many sites that uses this, so
perhaps there is an easier way I haven't thought of yet.Thank you / Moe
On 05/02/10 15:48, Moe wrote:
I am trying to figure out how I can introduce full text search "tips"...
tips meaning, like if you start typing Mer ..
then a box with a couple of words underneath comes up, with *Mercedes,
Mercury *and so on :PI am thinking that the word suggestions needs to come from the already
existing tsearch2 index.
Words that are frequent in the index could be ranked higher as a search tip.
This could get expensive if you have a large index. You might want to
summarize down to a separate (word,frequency) table. Particularly if you
don't want stemming to interfere with your suggestions.
See the manuals (full text search) for details on prefix searches -
introduced in 8.4 if you really want to go the tsearch route.
--
Richard Huxton
Archonet Ltd
On Thu, Feb 11, 2010 at 6:56 PM, Richard Huxton <dev@archonet.com> wrote:
On 05/02/10 15:48, Moe wrote:
I am trying to figure out how I can introduce full text search "tips"...
tips meaning, like if you start typing Mer ..
then a box with a couple of words underneath comes up, with *Mercedes,
Mercury *and so on :PI am thinking that the word suggestions needs to come from the already
existing tsearch2 index.
Words that are frequent in the index could be ranked higher as a search
tip.This could get expensive if you have a large index.
You might want to summarize down to a separate (word,frequency) table.
Particularly if you don't want stemming to interfere with your suggestions.
Stemming is ok. That's fine.
How would this normally be implemented? Should I go through my text word by
word myself, or the already existing index and copy over to a new table? Not
sure how this would be managable. Every change to something would require a
word count down, and then a word up after.
See the manuals (full text search) for details on prefix searches -
introduced in 8.4 if you really want to go the tsearch route.
I'll look into that.
--
Show quoted text
Richard Huxton
Archonet Ltd
On 11/02/10 17:11, Moe wrote:
You might want to summarize down to a separate (word,frequency) table.
Particularly if you don't want stemming to interfere with your suggestions.Stemming is ok. That's fine.
How would this normally be implemented? Should I go through my text word by
word myself, or the already existing index and copy over to a new table? Not
sure how this would be managable. Every change to something would require a
word count down, and then a word up after.
I wouldn't bother keeping it 100% up-to-date. You only want the
most-plausible suggestions anyway. Have a look at the ts_stat() function.
http://www.postgresql.org/docs/8.4/interactive/textsearch-features.html
Run it overnight, and summarise to a separate table, then just use
"like" against it.
Otherwise, like you say, your database will spend most of its time
adding up word counts etc.
--
Richard Huxton
Archonet Ltd