Module mod_search

Defines PostgreSQL queries for basic content searches in Zotonic.

Copyright © 2009 Marc Worrell Date: 2009-06-09

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Defines PostgreSQL queries for basic content searches in Zotonic. This module needs to be split in specific PostgreSQL queries and standard SQL queries when you want to support other databases (like MySQL).

Function Index

code_change/3Convert process state when code is changed.
find_by_id/2Find one more more resources by id or name, when the resources exists.
find_by_id/3As find_by_id/2, but when Rank is true, results contain a list of tuples: {id, 1}.
handle_call/3Trap unknown calls.
handle_cast/2Casts for updates to resources.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
observe_module_activate/2
observe_search_query/2
rank_behaviour/1The ranking behaviour for scoring words in a full text search See also: http://www.postgresql.org/docs/9.3/static/textsearch-controls.html.
rank_weight/1The weights for the ranking of the ABCD indexing categories.
start_link/1Starts the server.
terminate/2This function is called by a gen_server when it is about to terminate.
to_tsquery/2Expand a search string like "hello wor" to a PostgreSQL tsquery string.
trim/2

Function Details

code_change/3

code_change(OldVsn, State, Extra) -> {ok, NewState}

Convert process state when code is changed

find_by_id/2

find_by_id(S::string() | binary(), Context::z:context()) -> #search_result{}

Find one more more resources by id or name, when the resources exists. Input may be a single token or a comma-separated string. Search results contain a list of ids.

find_by_id/3

find_by_id(S::string() | binary(), Rank::boolean(), Context::z:context()) -> #search_result{}

As find_by_id/2, but when Rank is true, results contain a list of tuples: {id, 1}.

handle_call/3

handle_call(Message::Request, From, State) -> {reply, Reply, State} | {reply, Reply, State, Timeout} | {noreply, State} | {noreply, State, Timeout} | {stop, Reason, Reply, State} | {stop, Reason, State}

Trap unknown calls

handle_cast/2

handle_cast(Message::Msg, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Casts for updates to resources

handle_info/2

handle_info(Info, State) -> {noreply, State} | {noreply, State, Timeout} | {stop, Reason, State}

Handling all non call/cast messages

init/1

init(Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

observe_module_activate/2

observe_module_activate(Module_activate, Context) -> any()

observe_search_query/2

observe_search_query(X1, Context) -> any()

rank_behaviour/1

rank_behaviour(Context::#context{}) -> integer()

The ranking behaviour for scoring words in a full text search See also: http://www.postgresql.org/docs/9.3/static/textsearch-controls.html

rank_weight/1

rank_weight(Context::#context{}) -> string()

The weights for the ranking of the ABCD indexing categories. See also: http://www.postgresql.org/docs/9.3/static/textsearch-controls.html

start_link/1

start_link(Args) -> {ok, Pid} | ignore | {error, Error}

Starts the server

terminate/2

terminate(Reason, State) -> void()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

to_tsquery/2

to_tsquery(Tr::binary() | string() | {trans, list()} | undefined, Context::#context{}) -> binary()

Expand a search string like "hello wor" to a PostgreSQL tsquery string. If the search string ends in a word character then a wildcard is appended to the last search term.

trim/2

trim(S::binary() | string() | #trans{} | undefined, Context::z:context()) -> binary()


Generated by EDoc