Blogroll

Tuesday, September 11, 2012

Installing Sphinx 2.0.4 on Ubuntu 10.04 - Lucid


Description: “Sphinx  is a full-text search engine, distributed under GPL version 2. Commercial license is also available for embedded use. Generally, it’s a standalone search engine, meant to provide fast, size-efficient and relevant fulltext search functions to other applications. Sphinx was specially designed to integrate well with SQL databases and scripting languages. Currently built-in data sources support fetching data either via direct connection to MySQL or PostgreSQL, or using XML pipe mechanism (a pipe to indexer in special XML-based format which Sphinx recognizes). As for the name, Sphinx is an acronym which is officially decoded as SQL Phrase Index. Yes, I know about CMU’s Sphinx project“.
Installation:
  • Install the packages needed: apt-get install gcc make libmysqlclient15-dev libmysql++-dev
  • Download Sphinx from here .
  • Decompress it: tar xvfz sphinx-*.tar.gz
  • Enter its directory: cd sphinx-*
  • Run configure: ./configure --prefix=/usr/local/sphinx --with-mysql
  • Compile Sphinx: make
  • Install Sphinx (as root): make install
Configuration:
  • Enter Sphinx’s directory: cd /usr/local/sphinx/etc
  • Make a copy of its default configuration: cp sphinx.conf.dist sphinx.conf
  • Modify it to fit you database schema and preferences (I recommend reading Sphinx’s official documentation   and this tutorial by IBM  first).
  • Create all indexes: /usr/local/sphinx/bin/indexer --all
  • Something like this will be shown:

    Sphinx 0.9.9-rc2 (r1785)
    Copyright (c) 2001-2009, Andrew Aksyonoff
    using config file '/usr/local/sphinx/etc/sphinx.conf'...
    indexing index 'software'...
    collected 10 docs, 0.0 MB
    sorted 0.0 Mhits, 100.0% done
    total 10 docs, 649 bytes
    total 0.013 sec, 48970 bytes/sec, 754.54 docs/sec
    total 2 reads, 0.000 sec, 16.3 kb/call avg, 0.0 msec/call avg
    total 5 writes, 0.000 sec, 0.4 kb/call avg, 0.0 msec/call avg
Use:
  • You can perform a basic search using: /usr/local/sphinx/bin/search desired_word . It matches all words by default, but you can change this behaviour. Run/usr/local/sphinx/bin/search without arguments to show the available options.
  • Example: /usr/local/sphinx/bin/search samba
    Sphinx 0.9.9-rc2 (r1785)
    Copyright (c) 2001-2009, Andrew Aksyonoff


    using config file '/usr/local/sphinx/etc/sphinx.conf'...
    index 'software': query 'samba ': returned 1 matches of 1 total in 0.000 sec


    displaying matches:
    1. document=10, weight=2
    id=10
    url=http://www.samba.org/
    name=Samba
    description=Samba is a SMB/CIFS file, print, and login server. It seamlessly integrates Linux/Unix Servers and Desktops into Active Directory environments using the Winbind daemon.
    stable_version=3.4.3
    stable_date=2009-10-29
    download=http://www.samba.org/samba/ftp/stable/samba-3.4.3.tar.gz


    words:
    1. 'samba': 1 documents, 2 hits
The use of /usr/local/sphinx/bin/search is just for test and debugging purposes. There are native API ports for PHP, Python, Java, Perl, and Ruby. I will explain the integration between PHP  and Sphinx on another post.
Source :http://acidborg.wordpress.com/2009/11/22/how-to-install-and-configure-sphinx-in-ubuntu-9-10-with-mysql-support/

Note :use searchd --config "config file first";
then sudo indexer --config "config file" --all --rotate

Thursday, August 9, 2012

Install mongodb for windows

Follow some below step:
1. Download lasted version at http://www.mongodb.org/downloads and choose right version for your computer.
2. Extract zip file to somewhere, For me is c:\bin\mongodb.
3.Create folder that save mongodb data, For me is c:\data 
4.Open cmd and type cd c:\bin\mongodb\bin
5.Continue and cmd and type mongod --dbpath c:\data to run mongodb as services (c:\data is folder that created before).
In this step, mongdb is running, Remember don't close cmd because it's running.
To do testing with mongDb, do below step:
6. If have no error appear, It mean you installed mongodb  as services successful. Next test it working.
7.Open cmd and type  cd c:\bin\mongodb\bin and type another text is mongo and enter. Mongo shell will be apper.
8. Type code to insert to db db.test.save({a:'abc'}) , It mean add a with value is 'abc' to test collection
9.To show record in test collection , type code db.test.find()

Nodejs with mongodb

Today, I excited to research nodeJs and i find way  how to access db to Mongodb from nodeJS.
At first, install module mongodb for node in this link 
Wednesday, July 25, 2012

Regular express php

Regular express is language to description a group of string pattern. I used to validate url, email, phone, name,,..... Below is table definition some rule for regular express
Tuesday, July 17, 2012

Compress html with php

Compress html help you load page with faster speed, delete your html comment.
Fist : save out html and call function when page load done.
Put below code before show your html code.
Monday, July 16, 2012

13 useful query for wordpress


Change Siteurl & Homeurl

WordPress stores the absolute path of the site URL and home URL in the database. Therefore, if you transfer your WordPress site from the localhost to your server, your site will not load online. This is because the absolute path URL is still pointing to your localhost. You will need to change the site URL and the home URL in order for the site to work.
Solution:
1
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Friday, June 15, 2012

Remove new line php

I'll many way to remove new line in php. Some version not working in some code. Below is code almost working well
$string = preg_replace('@[\s]{2,}@',' ',$value);
$string  = trim(str_replace(array("/\n|\r/","\""),array("", "'"), $string));