On Mon, Oct 12, 2009 at 7:26 PM, Ivan Sergio Borgonovo <m...@webthatworks.it > wrote:
> On Mon, 12 Oct 2009 19:11:01 +0530 > Gaini Rajeshwar <raja.rajeshwar2...@gmail.com> wrote: > > > I think you misunderstood my question. let me give clear idea > > about what i need. > > > > I am using PostgreSQL fulltext search (tsearch2) feature to > > implement searching on database. From readings i came to know that > > we can give weights to different fields in database something like > > this: > > > > *setweight(to_tsvector(title),'A')* > > > > Where 'A' is weight given to field title. i can give weights to > > other fields in the same way. Where the weights 'A', 'B', 'C', 'D' > > are in will be in the following order *A > B > C > D* according to > > defalut fulltext search configuration. > > > > We can rank the search results using ts_rank function something > > like this, > > > > *ts_rank(tsv_title,ts_query('this is my search text'))* > > ** > > But, i want to rank these reults not only based on just title, but > > also using other fields like summary etc. > > Is there a way around to do this? > > if you concatenate your fields with different weight in the *same* > ts_vector, ranking will take into account your weight... > yes, ranking will take into account. but how can we specify just *one field at the time of searching* and specify *all the fields at the time of ranking?* > Someone more knowledgeable than me chose how to use weight to give a > > reasonable ranking. > > Of course if you've field a, b and c and you want to search in a and > b only, you'll have to concatenate just a and b. > > If you need different assortment in fields groups... you'll have to > add some extra redundancy if you plan to store precomputed > ts_vectors for each record. > > If you need to search "separately" in different fields > (eg. title ~ 'gino' AND summary ~ 'pino') > you just need to weight the input query as well > > inputquery := setweight(cfg, inputtitle, 'A', '&'); > inputquery := inputquery && setweight(cfg, inputsummary, 'B', '&'); > I didn't understand why did u use '&' operator in setweight function. is that going to help in any way? > > ... > > > > -- > Ivan Sergio Borgonovo > http://www.webthatworks.it > >