diff options
| author | yo mama <pepper@scannerjammer.com> | 2014-09-25 19:09:06 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2014-09-25 19:09:06 -0700 |
| commit | f68564b88dfb3ac08df2d01f883a0276883b96aa (patch) | |
| tree | 550edd360bb71c540894216d887bf046a4f20570 | |
| parent | f7b29b9ff4658be13c8573ce4303240b572c4e57 (diff) | |
added2
| -rw-r--r-- | DBIC_tests.pl | 56 | ||||
| -rw-r--r-- | sphinx.conf | 51 | ||||
| -rw-r--r-- | sphinx_commands.sh | 2 |
3 files changed, 109 insertions, 0 deletions
diff --git a/DBIC_tests.pl b/DBIC_tests.pl new file mode 100644 index 0000000..ec532d4 --- /dev/null +++ b/DBIC_tests.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use Data::Dumper; +use DateTime;#is that what was missing? could be +use lib 'lib'; +use JournalApp::Schema; + +my $entry = { + id => 12, + fulltext => "hello world test test test", + image_url => "http://myimage.com/new.png", + date => DateTime->now()->epoch, +}; +#our $schema = JournalApp::Schema->connect( 'dbi:SQLite:./journals.db', '', ''); +our $schema = JournalApp::Schema->connect( 'dbi:mysql:database=journal;host=localhost;port=3306', 'journal_user', 'journal_password', { + quote_names => 1 +}); + +sub test_remove_from_db{ + #delete by id + my $journalentry = $schema->resultset('Journal')->find({ id => $entry->{id} }); + +$journalentry->delete(); +} + + + +sub test_get_entry_by_date{ + my $res = $schema->resultset('Journal')->search({ + -and => [ + date => { '>', DateTime->now()->epoch - 3600 * 24 * 2 }, + date => { '<=', DateTime->now()->epoch }, + ] + }, { + order_by => "date" + } + ); + foreach my $row ($res->all){ + print Dumper $row->id; #so it just didn't find anything? looks so yeah just needed <= + } + +} + +sub test_add_journal_entry{ + my $journalentry = $schema->resultset('Journal')->create($entry); + if ($journalentry){ print "added sucessfully\n"} else { "add failed\n" }; + return $journalentry; +} + +#how do I connect? + +sub main{ + test_add_journal_entry; + test_get_entry_by_date; + test_remove_from_db; +} +main(); diff --git a/sphinx.conf b/sphinx.conf new file mode 100644 index 0000000..24d271b --- /dev/null +++ b/sphinx.conf @@ -0,0 +1,51 @@ +source journal +{ + type = mysql + sql_host = localhost + sql_user = journal_user + sql_pass = journal_password + sql_db = journal +# sql_sock = /var/run/mysqld/mysqld.sock + sql_port = 3306 + + # indexer query + # document_id MUST be the very first field + # document_id MUST be positive (non-zero, non-negative) + # document_id MUST fit into 32 bits + # document_id MUST be unique + sql_query = \ + SELECT \ + `id`, `fulltext`, `image_url` \ + FROM \ + journals; +# +# sql_group_column = assembly +# sql_group_column = model + + # document info query + # ONLY used by search utility to display document information + # MUST be able to fetch document info by its id, therefore + # MUST contain '$id' macro + # + + sql_query_info = SELECT * FROM journals WHERE id=$id +} + +index journal +{ + source = journal + path = /home/pepper/sphinx/journal + morphology = stem_en + + min_word_len = 3 + min_prefix_len = 0 + min_infix_len = 3 +} + +searchd +{ + port = 3312 + log = /var/log/searchd/searchd.log + query_log = /var/log/searchd/query.log + pid_file = /var/log/searchd/searchd.pid +} diff --git a/sphinx_commands.sh b/sphinx_commands.sh new file mode 100644 index 0000000..d721456 --- /dev/null +++ b/sphinx_commands.sh @@ -0,0 +1,2 @@ +sudo sphinx-indexer journal +sudo sphinx-searchd |
