Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (80 sloc) 2.09 KB
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw/$Bin/;
use lib "$Bin/../lib";
use FindmJob::Basic;
my $root = FindmJob::Basic->root;
mkdir("$root/sphinxdata") unless -d "$root/sphinxdata";
die "Can't create $root/sphinxdata" unless -d "$root/sphinxdata";
mkdir("$root/log") unless -d "$root/log";
my $config = FindmJob::Basic->config;
my ($dns, $user, $pass) = @{$config->{DBI}};
my ($host) = ($dns =~ /host=(.*?)(\:|$)/); $host ||= 'localhost';
my ($port) = ($dns =~ /port=(.*?)(\:|$)/); $port ||= '3306';
my ($database) = ($dns =~ /database=(.*?)(\:|$)/); $host ||= 'findmjob';
print <<CONF;
source job {
type = mysql
sql_host = $host
sql_user = $user
sql_pass = $pass
sql_db = $database
sql_port = $port
CONF
print <<'CONF';
sql_query_pre = SET NAMES utf8
sql_query_pre = SET @id := 1;
sql_query = \
SELECT @id := @id + 1 AS tid, id, 'job' as tbl, title, description, location, contact, inserted_at FROM job WHERE expired_at > NOW()
sql_field_string = id
sql_field_string = tbl
sql_attr_uint = inserted_at
sql_ranged_throttle = 0
}
source freelance : job {
sql_query = \
SELECT @id := @id + 1 AS tid, id, 'freelance' as tbl, title, description, 'Anywhere' as location, contact, inserted_at FROM freelance WHERE expired_at > NOW()
}
index job {
# index type
# optional, default is 'plain'
# known values are 'plain', 'distributed', and 'rt' (see samples below)
# type = plain
source = job
CONF
print <<CONF;
path = $root/sphinxdata/job
docinfo = extern
mlock = 0
morphology = none
min_word_len = 3
charset_type = utf-8
html_strip = 0
}
index freelance : job {
source = freelance
path = $root/sphinxdata/freelance
}
indexer {
mem_limit = 32M
}
searchd {
listen = 9312
log = $root/log/searchd.log
query_log = $root/log//query.log
read_timeout = 5
client_timeout = 300
max_children = 30
pid_file = $root/log/searchd.pid
max_matches = 800
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
mva_updates_pool = 1M
max_packet_size = 8M
max_filters = 256
max_filter_values = 4096
}
CONF
1;