Coder Social home page Coder Social logo

cat-of-devil / fulltext-search-utility Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ovaistariq/fulltext-search-utility

0.0 2.0 0.0 93 KB

A utility PHP class for building search query from user search terms that can be used to do a MySQL Boolean FullTEXT search

PHP 100.00%

fulltext-search-utility's Introduction

=== Description
This is a search utility that i developed that parses a search query submitted by user and converts it into Boolean Full Text Search query that can be used in SQL with all the words stemmed to their base word.

=== Installation
No installation is needed, just copy the two files search.php and wordstemmer.php to your project and include them:

include "wordstemmer.php";
include "search.php";

=== Requirements
PHP version 5+

=== wordstemmer.php
External package with implementation of Porter Stemming algorithm.

=== search.php
The class that generates the Boolean Full Text search query from user submitted search terms.

=== Usage
Usage is pretty simple. First you need to create an object of the search library, by passing it the search query that user has submitted:

$lib_search = new Libs_Search('some user search string here');

Next you would need to call the method GetSearchQueryString and it would return the query string that you can use in your searches:

$query_string = $lib_search->GetSearchQueryString();

Now you can use the generated query string as follows:

$sql = "SELECT * FROM tbl where MATCH(txt_col) AGAINST('$query_string' IN BOOLEAN MODE)";
mysql_query( $sql );

=== Examples
-- Example 1
$lib_search = new Libs_Search("Life's");
echo $lib_search->GetSearchQueryString(); // This will echo life*

-- Example 2
$lib_search = new Libs_Search("Life's making");
echo $lib_search->GetSearchQueryString(); // This will echo life* make*

-- Example 3
$lib_search = new Libs_Search("Annie's and Song");
echo $lib_search->GetSearchQueryString(); // This will echo +ann* +song*

fulltext-search-utility's People

Contributors

ovaistariq avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.