full text search index

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Patrick Baker <patrickbakerbr(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: full text search index
Date: 2016-05-26 04:25:58
Message-ID: CAKFQuwajDG=GPDJ9tkyTFPY1BRo4RfehjRbphYEB6NRX5AFOXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, May 26, 2016, Patrick Baker <patrickbakerbr(at)gmail(dot)com> wrote:

> Hi there,
>
> I've got the following query:
>
>>
>> SELECT COUNT(DISTINCT j0_.id) AS sclr10
>> FROM customers j0_
>> WHERE ((LOWER(j0_.name_first) LIKE '%some%'
>> OR LOWER(j0_.name_last) LIKE '%some%')
>> AND j0_.id = 5)
>> AND j0_.id = 5
>
>
> The query is taking ages to run.
>
> I read about wildcards and it seems I have to use a function with to_tsvector
> ?
>
>>
>> CREATE INDEX CONCURRENTLY ON public.customers USING gin ("clientid",
>> ("full_text_universal_cast"("name_first"::"text")),
>> ("full_text_universal_cast"("name_last"::"text")));
>
>
> full_text_universal_cast:
>
>> CREATE OR REPLACE FUNCTION public.full_text_universal_cast(doc_data
>> "text")
>> RETURNS "tsvector" AS
>> $BODY$
>> SELECT to_tsvector('english', COALESCE(TRIM(CAST(doc_data AS TEXT)), ''));
>> $BODY$
>> LANGUAGE sql IMMUTABLE
>> COST 1000;
>
>
>
>
> Would be something like above? Because it's not working...
>
> What am I missing guys?
> Thanks
>

Maybe Lucas Possamai can help. He seems to be a little bit further along
in this exercise.

I'm too tired to care at the moment. And I haven't had much practical work
here anyway.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrej Vanek 2016-05-26 09:20:23 Re: empty pg_stat_replication when replication works fine?
Previous Message Patrick Baker 2016-05-26 04:04:56 full text search index