+CREATE OR REPLACE FUNCTION rank_exact_matches(rank float) RETURNS float AS $$
+begin
+ IF rank = 0 THEN
+ return 1;
+ ELSE
+ return rank;
+ END IF;
+
+end
+$$ LANGUAGE plpgsql;
+
+CREATE OR REPLACE FUNCTION public.rebuild_index() RETURNS VOID as $$
+ DECLARE
+ r integer;
+ BEGIN
+ FOR r IN SELECT active_revision_id FROM forum_node WHERE node_type = 'question' LOOP
+ UPDATE forum_noderevision SET id = id WHERE id = r;
+ END LOOP;
+ END
+$$ LANGUAGE 'plpgsql';
+
+SELECT rebuild_index();