mnoGoSearch 3.3.4 reference manual: Full-featured search engine software
Prev |  | Next

# DBAddr

## Name

DBAddr -- sets database address

indexer.conf search.htm

## Synopsis

DBAddr {{DBType}:[//[DBUser[:DBPass]@]DBHost[:DBPort]]/DBName/[?DBMode=mode]}

## Description

This command defines URL-style database address.

Type, host, database name, port, user and password are options to connect to SQL database.

Must be used before any other commands. Has global effect on the whole configuration file.

ODBC notes: Use DBName to specify ODBC Data Source Name (DSN) DBHost does not matter, so use "localhost".

Currently supported DBType values are mysql, pgsql, mssql, sybase, oracle, ibase, db2, mimer, sqlite, sqlite3, cache.

If you are using PostgreSQL and do not specify hostname, e.g.

    pgsql://user:password@/dbname/

mnoGoSearch will communicate with PostgreSQL using a Unix socket rather than a TCP port.

MySQL and PostgreSQL users can specify path to Unix socket when connecting to localhost:

    DBAddr mysql://foo:bar@localhost/mnogosearch/?socket=/tmp/mysql.sock
    DBAddr pgsql://foo:bar@/mnogosearch/?socket=/tmp/s.PGSQL.5432

MySQL users can specify whether to switch MySQL query logging on/off using sqllog parameter:

    DBAddr mysql://foo:bar@localhost/mnogosearch/?sqllog=0
    DBAddr mysql://foo:bar@localhost/mnogosearch/?sqllog=1

If sqllog parameter is given, then mnoGoSearch will send "SET SQL_LOG_OFF=X" query after connection is established. Only users with MySQL `SUPER` privilege can use this parameter.

MySQL users can specify whether to do binary by setting the `sqllogbin` parameter:

    DBAddr mysql://foo:bar@localhost/mnogosearch/?sqllogbin=0
    DBAddr mysql://foo:bar@localhost/mnogosearch/?sqllogbin=1

If sqllog parameter is given, then mnoGoSearch will send "SET SQL_LOG_BIN=X" after connection is established. Only users with MySQL `SUPER` privilege can use this parameter.

When initializing connection to MySQL, mnoGoSearch forces loading of my.cnf configuration file with the "client" option group by default. Use MyCnfGroup=group to load options from another group, or MyCnfGroup=no to prevent loading of my.cnf file:

    # Load options from another option group
    DBAddr mysql://foo:bar@localhost/mnogosearch/?MyCnfGroup=mnogosearch

    # Prevent loading my.cnf
    DBAddr mysql://foo:bar@localhost/mnogosearch/?MyCnfGroup=no

When connecting to MySQL, mnoGoSearch uses this MySQL C API call to tell the MySQL connection handler which option group to load (unless MyCnfGroup=no is specified):

    mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, MyCnfGroup);

MySQL users can specify session character set, alternative to the MySQL default (or loaded from my.cnf) value by specifying the `setnames` parameter:

    DBAddr http://root@localhost/test/?setnames=cp1251
    DBAddr http://root@localhost/test/?setnames=utf8

If a non-empty `setnames` value is specified, MySQL driver will send a `SET NAMES` query after connection is established.

The "DBMode" optional patameter value is "single", "multi" or "blob". Default mode is "single".

Some special characters, if they appear as a password part, need to be escaped using %XX notation, where XX is a hex code. Use %3A for ":", %3B for ";", %3C for "<", %3D for "=", %3E for ">", %3F for "?" and %40 for "@" characters. For example,

    DBAddr pgsql://user:pwd%3Awith%40special%3Cchars@/search/

corresponds to the local PostgreSQL database "search" with user name "user" and password "pwd:with@special<chars".

Starting with 3.2.36 DBAddr supports Deflate=yes|no parameter. With "Deflate=yes" specified, indexer compresses data when converting with "indexer -Eblob", which makes smaller database size and faster search. This option is effective for DBMode=blob only. There is no need to specify this option in search template, mnogosearch will detect and handle compressed data automatically while searching.

    DBAddr mysql://foo:bar@localhost/mnogosearch/?DBMode=blob&Deflate=yes

Starting with 3.2.36 DBAddr supports zint4=yes|no parameter. With "zint4=yes" specified, indexer compresses document IDs using a special compression method which we called "zint4". This compression method is as effective as possible: it compresses data up to 85% with relative good decompression speed. In conjunction with Deflate=yes parameter, compression ratio can be up to 99.8%. This option is effective for DBMode=blob, for '#rec_id' field only.

    DBAddr mysql://foo:bar@localhost/mnogosearch/?DBMode=blob&Deflate=yes&zint4=yes

Starting with 3.3.0 its possible to specify wf=XXXX parameter for DBAddr search.htm command. Starting from 3.3.3, nwf=XXXX is also allowed. These parameters are useful if you merge two or more databases and want to give more score to results coming from a desired database. The DBAddr parameters have higher precedence over the search query parameters, e.g. if "wf" is specified as a DBAddr parameter, then the global "wf" values (specified in QUERY_STRING or using wf search.htm command) are not used anymore. Format of the "wf" and "nwf" DBAddr parameters is similar to the one described in the Section called Changing different document parts weights at search time in Chapter 8.

    DBAddr mysql://root@localhost/db1/?wf=FFFF
    DBAddr mysql://root@localhost/db2/?wf=1111
    DBAddr mysql://root@localhost/db3/?wf=1111

Starting with 3.3.0, the MaxResults=num parameter was added for DBAddr search.htm command - to specify the maxumn number of search results to return from the database. It can be useful to add a limited number of sponsored links in the top of search results:

    DBAddr mysql://root@localhost/avd/?wf=FFFF=1&MaxResults=1
    DBAddr mysql://root@localhost/db1/?wf=1111
    DBAddr mysql://root@localhost/db2/?wf=1111

Starting from 3.3.3, the DebugSQL=yes/no parameter is understood. When DebugSQL is set to `yes`, indexer and search.cgi will print all SQL queries sent to the database. mnoGoSearch must be compiled with `--with-debug`, otherwise DebugSQL=yes is ignored.

    DBAddr mysql://root@localhost/test/?DebugSQL=yes

## Examples

    DBAddr mysql://foo:bar@localhost/mnogosearch/?DBMode=multi
    DBAddr mysql://foo:pwd%3Awith%40special%3Cchars@localhost/mnogosearch/

Prev | Home | Next
DateFormat | Up | DefaultContentType