DBAddr

Name

DBAddr -- sets database address

indexer.conf search.htm

Synopsis

DBAddr {type://[user[:password]@]hostname[:port]/dbname/[?DBMode=mode][&param1=value1...]}

Description

The DBAddr command defines a database mnoGoSearch will use for indexing or search, using URL-style notation. It must be used before any other commands, and has global effect on the entire configuration file. Multiple DBAddr entries are possible in the case of a distributed search engine (see the Section called mnoGoSearch cluster in Chapter 5).

Type, hostname, dbname, user, password and port are the most important parts of a DBAddr command. The main part of a DBAddr command can also be followed by a number of additional parameters, like DBMode.

The main part is separated from the parameters part using the QUESTION MARK (?), and the parameters are separated from each other using the AMPERSAND SIGN (&).

Notes on type

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

Notes on hostname

An empty host name with PostgreSQL, e.g.


pgsql://user:password@/dbname/
means that mnoGoSearch will communicate with PostgreSQL server using a Unix socket rather than a TCP port.

Hostname is not important when describing an ODBC database (e.g. on Windows, or on Unix when mnoGoSearch is compiled with UnixODBC or iODBC support). Specifying ODBC Data Source Name (DSN) in the dbname is enough, so the hostname can be either omitted or can be set to "localhost":


mysql://root@/myodbc/
mysql://root@localhost/myodbc/

Special characters in user and password

Some special characters, if they appear as a user name or in a password, 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".

The DBMode parameter

The "DBMode" optional parameter can be set to on of the three values: "single", "multi" or "blob". The default value is "single". See the Section called SQL storage types in Chapter 5 for details.

The Socket parameter

MySQL and PostgreSQL users can specify a path to Unix socket when connecting to a server running on the local machine:


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

The SetNames parameter

MySQL and PostgreSQL users can set connection character set by specifying the setnames parameter. It is important if the default MySQL or PostgreSQL client character set settings do not correspond to the LocalCharset setting of mnoGoSearch.


LocalCharset utf8
DBAddr http://root@localhost/test/?setnames=utf8
If a non-empty setnames value is specified, MySQL and PostgreSQL drivers will send a SET NAMES query after connection is established.

Parameters affecting score (wf and nwf)

Starting with 3.3.0 its possible to specify wf=XXXX parameter for DBAddr command in search.htm. 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

The MaxResults parameter

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

The DebugSQL parameter

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

The TrackQuery parameter

Use trackquery=yes parameter to activate tracking of search queries. Please refer to the Section called Search query tracking in Chapter 8 for details on qiery tracking.

Parameters related to DBMode=blob

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

MySQL specific parameters

MyCnfGroup - Loading my.cnf file

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 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);

SQLLog - Using general log

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.

SQLLogBin - Using binary log

MySQL users can specify whether to do binary logging 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.

Examples


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