472,328 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Tsearch2 lexeme position

Hi,

Is it possible to get all the positions of a lexeme in a result-set of a
query? For example, we have the table

TEXT TEXT_IDX
'TSearch2 is very cool' ...

'It would be much cooler with lexeme positions'

Our query is
SELECT text, position FROM thetable WHERE text_idx @@ 'cool'::tsquery;
^^^^^^^^
The result should be something like:
'TSearch2 is very cool', 4
'It would be much cooler with lexeme positions', 5

If not, is there a function that returns the positions of a lexeme in a
single entry?

thanks
Alex

--
Dipl.-Inform. Alexander Rueegg
Bioinformatics Department Faculty of Technology
Bielefeld University
Phone: +49 (0)521-106-3541
Fax: +49 (0)521-106-6488
Room: C02-206
Email: ar*****@techfak.uni-bielefeld.de


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #1
4 2572


Alexander Regg wrote:
Hi,

Is it possible to get all the positions of a lexeme in a result-set of a
query? For example, we have the table

TEXT TEXT_IDX
'TSearch2 is very cool' ...

'It would be much cooler with lexeme positions'

Our query is
SELECT text, position FROM thetable WHERE text_idx @@ 'cool'::tsquery;
^^^^^^^^
The result should be something like:
'TSearch2 is very cool', 4
'It would be much cooler with lexeme positions', 5

If not, is there a function that returns the positions of a lexeme in a
single entry?


You can write such function, but why do you need it? May be there is more simple
way to resolve your problem?

BTW, lexeme can have more that one position...

--
Teodor Sigaev E-mail: te****@sigaev.ru
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #2
Thank you for your response.
We want to know the distance or sequence of words in a set of
text-entries. So first we try to retrieve the text-entries in which the
words appear using tsearch indexing. After that we want to calculate the
positions of the words in each entry, e.g. parsing the index column of
the retrieved text-entries.
Maybe there exists a function or an easier/cheaper way to get this
information (and which considers that the words maybe occur more than once).

thanks,
Alex

Teodor Sigaev wrote:


Alexander Regg wrote:
Hi,

Is it possible to get all the positions of a lexeme in a result-set of a
query? For example, we have the table

TEXT TEXT_IDX
'TSearch2 is very cool' ...

'It would be much cooler with lexeme positions'

Our query is
SELECT text, position FROM thetable WHERE text_idx @@ 'cool'::tsquery;
^^^^^^^^
The result should be something like:
'TSearch2 is very cool', 4
'It would be much cooler with lexeme positions', 5

If not, is there a function that returns the positions of a lexeme in a
single entry?


You can write such function, but why do you need it? May be there is
more simple way to resolve your problem?

BTW, lexeme can have more that one position...

--

Alexander Rueegg
Email: ar*****@uni-bielefeld.de

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #3
Alexander,

we'd be glad to add such function to tsearch2 in case it'd be useful
for many peoples, not just you.

Oleg
On Thu, 14 Aug 2003, Teodor Sigaev wrote:


Alexander Regg wrote:
Thank you for your response.
We want to know the distance or sequence of words in a set of
text-entries. So first we try to retrieve the text-entries in which the
words appear using tsearch indexing. After that we want to calculate the
positions of the words in each entry, e.g. parsing the index column of
the retrieved text-entries.
Maybe there exists a function or an easier/cheaper way to get this
information (and which considers that the words maybe occur more than
once).


No, it is not exists. The easiest way is to extract this info from tsvector value.


thanks,
Alex

Teodor Sigaev wrote:


Alexander Regg wrote:

Hi,

Is it possible to get all the positions of a lexeme in a result-set of a
query? For example, we have the table

TEXT TEXT_IDX
'TSearch2 is very cool' ...

'It would be much cooler with lexeme positions'

Our query is
SELECT text, position FROM thetable WHERE text_idx @@ 'cool'::tsquery;
^^^^^^^^
The result should be something like:
'TSearch2 is very cool', 4
'It would be much cooler with lexeme positions', 5

If not, is there a function that returns the positions of a lexeme in a
single entry?
You can write such function, but why do you need it? May be there is
more simple way to resolve your problem?

BTW, lexeme can have more that one position...



Regards,
Oleg
__________________________________________________ ___________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: ol**@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #4


Alexander Regg wrote:
Thank you for your response.
We want to know the distance or sequence of words in a set of
text-entries. So first we try to retrieve the text-entries in which the
words appear using tsearch indexing. After that we want to calculate the
positions of the words in each entry, e.g. parsing the index column of
the retrieved text-entries.
Maybe there exists a function or an easier/cheaper way to get this
information (and which considers that the words maybe occur more than
once).
No, it is not exists. The easiest way is to extract this info from tsvector value.


thanks,
Alex

Teodor Sigaev wrote:


Alexander Regg wrote:
Hi,

Is it possible to get all the positions of a lexeme in a result-set of a
query? For example, we have the table

TEXT TEXT_IDX
'TSearch2 is very cool' ...

'It would be much cooler with lexeme positions'

Our query is
SELECT text, position FROM thetable WHERE text_idx @@ 'cool'::tsquery;
^^^^^^^^
The result should be something like:
'TSearch2 is very cool', 4
'It would be much cooler with lexeme positions', 5

If not, is there a function that returns the positions of a lexeme in a
single entry?


You can write such function, but why do you need it? May be there is
more simple way to resolve your problem?

BTW, lexeme can have more that one position...


--
Teodor Sigaev E-mail: te****@sigaev.ru
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Nigel J. Andrews | last post by:
This will be a little vague, it was last night and I can't now do the test in that db (see below) so can't give the exact wording. I seem to...
1
by: psql-mail | last post by:
I have applied the recent tsearch2 patch and recompiled the tsearch2 module but I am still experiencing the same backend crashes as I previously...
1
by: mailinglists | last post by:
Hello, First of all I want to say that I really like this tsearch2 - it's a really great addition to Postgres!.. I am having one minor issue...
9
by: Pavel Stehule | last post by:
Hello I try tsearch2 within czech environment. It is works fine, but I have two questions. 1. I have words "se", "ve" in my czech stop words....
16
by: Ben | last post by:
I'm trying to make myself a dictionary for tsearch2 that converts numbers to their english word equivalents. This seems to be working great, except...
2
by: Fischer Ulrich | last post by:
Hi I have a problem with the restoring of a database which uses tsearch2. I made a backup as discribed in 'tsearch-v2-intro' on the tsearch2...
0
by: Markus Wollny | last post by:
Hi! Sorry to bother you, but I just don't know how to get tsearch2 configured correctly for my setup. I've got a 7.4.3 database-cluster initdb'ed...
3
by: Marcel Boscher | last post by:
Hello everybody, i tried to "J.U.S.T" install the FullTextSearchTool tsearch2 under the guidiance of :...
2
by: Net Virtual Mailing Lists | last post by:
Hello, If I have a rule like this: CREATE OR REPLACE RULE sometable_update AS ON UPDATE TO table2 DO UPDATE cache SET updated_dt=NULL WHERE...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.