Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » PostgreSQL »

duda con tsearch

Estas en el tema de duda con tsearch en el foro de PostgreSQL en Foros del Web. hola actualmente estoy creando un proyecto siguiendo los pasos de un libro en pdf . en especifico el Apress.Neginning PHP and Postgress. he llegado al ...
  #1 (permalink)  
Antiguo 15/11/2011, 13:39
 
Fecha de Ingreso: noviembre-2011
Mensajes: 2
Antigüedad: 12 años, 5 meses
Puntos: 0
duda con tsearch

hola actualmente estoy creando un proyecto siguiendo los pasos de un libro en pdf . en especifico el Apress.Neginning PHP and Postgress.
he llegado al capitulo de crear el buscador de la pagina, bueno lo dicho me he topado con lo siguiente .

ERRNO: 256
TEXT: SQLSTATE[42883]: Undefined function: 7 ERROR: function rank(tsvector, tsquery) does not exist
LINE 1: ...FROM product WHERE search_vector @@ $1 ORDER BY rank(searc...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT product_id, name, description, price, discounted_price, thumbnail FROM product WHERE search_vector @@ $1 ORDER BY rank(search_vector, $1 ) DESC LIMIT $2 OFFSET $3
CONTEXT: PL/pgSQL function "catalog_search" line 30 at FOR over SELECT rows
LOCATION: C:\xampp\htdocs\hatshop\business\database_handler. php, line 85, at November 15, 2011, 7:59 pm
Showing backtrace:
trigger_error("SQLSTATE[42883]: Undefined function: 7 ERROR: function rank(tsv...", "256") # line 85, file: C:\xampp\htdocs\hatshop\business\database_handler. php
DatabaseHandler.Execute(Object: PDOStatement, Array[5]) # line 99, file: C:\xampp\htdocs\hatshop\business\database_handler. php
DatabaseHandler.GetAll(Object: PDOStatement, Array[5]) # line 241, file: C:\xampp\htdocs\hatshop\business\catalog.php
Catalog.Search("yankee", "off", "1", "1") # line 57, file: C:\xampp\htdocs\hatshop\presentation\smarty_plugin s\function.load_products_list.php
ProductsList.init() # line 7, file: C:\xampp\htdocs\hatshop\presentation\smarty_plugin s\function.load_products_list.php
smarty_function_load_products_list(Array[1], Object: Page) # line 5, file: C:\xampp\htdocs\hatshop\presentation\templates_c\% %10^108^1083067C%%products_list.tpl.php
include("C:\xampp\htdocs\hatshop\presentation\temp lates_c\%%10^108^108306...") # line 1869, file: C:\xampp\htdocs\hatshop\libs\smarty\Smarty.class.p hp
Smarty._smarty_include(Array[2]) # line 6, file: C:\xampp\htdocs\hatshop\presentation\templates_c\% %B6^B60^B609D7CD%%search_results.tpl.php
include("C:\xampp\htdocs\hatshop\presentation\temp lates_c\%%B6^B60^B609D7...") # line 1869, file: C:\xampp\htdocs\hatshop\libs\smarty\Smarty.class.p hp
Smarty._smarty_include(Array[2]) # line 39, file: C:\xampp\htdocs\hatshop\presentation\templates_c\% %45^45E^45E480CD%%index.tpl.php
include("C:\xampp\htdocs\hatshop\presentation\temp lates_c\%%45^45E^45E480...") # line 1256, file: C:\xampp\htdocs\hatshop\libs\smarty\Smarty.class.p hp
Smarty.fetch("index.tpl", null, null, true) # line 1106, file: C:\xampp\htdocs\hatshop\libs\smarty\Smarty.class.p hp
Smarty.display("index.tpl") # line 34, file: C:\xampp\htdocs\hatshop\index.php

esto cuando trato de buscar algo con el boton.
cuando cree la funcion catalog search no me arrojo ningun error eh aqui la funcion

-- Create catalog_search function
CREATE FUNCTION catalog_search(TEXT[], VARCHAR(3), INTEGER, INTEGER, INTEGER)
RETURNS SETOF product_list LANGUAGE plpgsql AS $$
DECLARE
inWords ALIAS FOR $1;
inAllWords ALIAS FOR $2;
inShortProductDescriptionLength ALIAS FOR $3;
inProductsPerPage ALIAS FOR $4;
inStartPage ALIAS FOR $5;
outProductListRow product_list;
query TEXT;
search_operator VARCHAR(1);
query_string TSQUERY;
BEGIN
-- Initialize query with an empty string
query := '';
-- All-words or Any-words?
IF inAllWords = 'on' THEN
search_operator := '&';
ELSE
search_operator := '|';
END IF;
-- Compose the search string
FOR i IN array_lower(inWords, 1)..array_upper(inWords, 1) LOOP
IF i = array_upper(inWords, 1) THEN
query := query||inWords[i];
ELSE
query := query||inWords[i]||search_operator;
END IF;
END LOOP;
query_string := to_tsquery(query);
-- Return the search results
FOR outProductListRow IN
SELECT product_id, name, description, price,
discounted_price, thumbnail
FROM product
WHERE search_vector @@ query_string
ORDER BY rank(search_vector, query_string) DESC
LIMIT inProductsPerPage
OFFSET inStartPage
LOOP
IF char_length(outProductListRow.description) >
inShortProductDescriptionLength THEN
outProductListRow.description :=
substring(outProductListRow.description, 1,
inShortProductDescriptionLength) || '...';
END IF;
RETURN NEXT outProductListRow;
END LOOP;
END;
$$;


mi version del postgress la 8.3 .... saludos...
  #2 (permalink)  
Antiguo 15/11/2011, 14:09
 
Fecha de Ingreso: noviembre-2011
Mensajes: 2
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: duda con tsearch

ya lo resolvi jejeje es ts_rank no rank bueno al menos en esta version :D saludos

Etiquetas: end, postgres, sql, trigger
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:19.