PHP Classes

PHP SuperEzSearch: Search documents storing indexes in PHP structures

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-05-21 (9 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 48 All time: 10,652 This week: 24Up
Version License PHP version Categories
phpsuperezsearch 1.0BSD License7Databases, Searching, Text processing, P...
Description 

Author

This package can search documents storing indexes in PHP structures.

It can create a search index for text document strings in PHP data structures stored in class variables.

The package can also search for given keywords and return the identifiers of the text documents indexed previously.

It can also return text documents related to given documents indexed by the package.

The search keyword may include negative work that should be excluded from the list of documents that the package returns as search results.

The database index can be saved by returning a string of data with the serialized version of the database index class variables so that the same index can be loaded by the package later.

The database index data can be in a binary format that may be compressed. It can also store the index data in session variables.

Picture of JImmy Bo
  Performance   Level  
Name: JImmy Bo is available for providing paid consulting. Contact JImmy Bo .
Classes: 14 packages by
Country: United States United States
Age: ???
All time rank: 1212173 in United States United States
Week rank: 14 Up3 in United States United States Up
Innovation award
Innovation award
Nominee: 8x

Winner: 1x

Example

<?php
   
/*
        example usage of class: PHP_SuperEzSearch
        This class is a simple search engine that uses sequence matching of two character sequences to match documents and documents to phrases.
        It allows for negative queries to be used to exclude documents from the search results.
        Negative prompt works meh, but it works a bit for the most part.
    */

   
require_once('class.phpsuperezsearch.php');

   
ob_start();
   
session_start();

   
// Usage example
   
$ez = new PHP_SuperEzSearch();

   
$ez->addDocument('a', "This is a sample document.");
   
$ez->addDocument('b', "Another document in the database.");
   
$ez->addDocument('c', "Yet another sample document with different content.");
   
$ez->addDocument(1, 'The quick yellow fox jumps over the lazy dog');
   
$ez->addDocument(2, 'The quick brown dog jumps over the lazy fox');
   
$ez->addDocument(3, 'The sleeping dog is a walrus and is friends with the blue fox.');
   
$ez->addDocument(4, 'A quick brown fox and a quick brown dog are friends');
   
$ez->addDocument('/folder/folder/filename.txt', "I like chicken on my potato salad, said the dog.");
   
$ez->addDocument('/folder/x.nfo', "a title of a story somewhere about the fox and the hen.");
   
   
// Index multiple documents at once
   
$documentArray = [
       
'5' => 'The quick brown goat is faster than the lazy dog',
       
'6' => 'The sleepy brown dog is slower than the quick blue zebra',
    ];

   
$ez->indexDocuments($documentArray);

    echo
"testing search...\r\n<br />";

   
// test no match
   
print("You search for 'aardvark' and we found the following results:\n<br />");
   
$results = $ez->search("arrdvark");
   
print_r($results);

   
// test some matches
   
$q = "The green dog is slower than the quick brown goat";
    print(
"You search for [$q] and we found the following results:\n<br />");
   
$results = $ez->search($q);
   
print_r($results);
   
   
$q = "is a";
    print(
"You search for [$q] and we found the following results:\n<br />");
   
$results = $ez->search($q);
   
print_r($results);

   
// test negative queries
   
echo "testing negative queries...\r\n<br />";

   
$q = "document";
    print(
"You search for [$q] and we found the following results:\n<br />");
   
$results = $ez->search($q);
   
print_r($results);
   
$neg_q = "con";
    print(
"You search for [$q] and negative query [".print_r($neg_q,1)."] and we found the following results:\n<br />");
   
$results = $ez->search($q, 5, $neg_q);
   
print_r($results);


   
$q = "dog";
    print(
"You search for [$q] and we found the following results:\n<br />");
   
$results = $ez->search($q);
   
print_r($results);
   
$neg_q = "fox";
    print(
"You search for [$q] and negative query [".print_r($neg_q,1)."] and we found the following results:\n<br />");
   
$results = $ez->search($q, 5, $neg_q);
    echo
"-=-=-=\r\n<br />";
   
print_r($results);

   
// test return related documents
   
$results = $ez->returnRelatedDocuments('a', 15);
    echo
"\r\n<br />-= returning related items for document id 'a' -=-=\r\n<br />";
   
print_r($results);
    echo
"\r\n<br />-=-=-=\r\n<br />";

   
// example remove some documents
   
$ez->removeDocument('a');
   
$ez->removeDocument(4);

    echo
"Now testing save/load...\r\n<br />";

   
// save to session //
    // $ez->save_to_session('db');
    // $ez2 = new PHP_SuperEzSearch();
    // $ez2->load_from_session('db');
    // print_r($ez2->documentVectors);

    // save binary
    // $ez->save('db.bin');
    // $ez3 = new PHP_SuperEzSearch();
    // $ez3->load('db.bin');
    // print_r($ez3->documentVectors);

    // save compressed
   
$ez->save_compressed('db.gz');
   
$ez4 = new PHP_SuperEzSearch();
   
$ez4->load_compressed('db.gz');
   
print_r($ez4->documentVectors);




   
// print_r($ez->documentVectors);
?>


  Files folder image Files  
File Role Description
Plain text file class.phpsuperezsearch.php Class the class file for php superezsearch
Accessible without login Plain text file example.phpsuperezsearch.output.txt Output example output
Accessible without login Plain text file example.phpsuperezsearch.php Example example usage

 Version Control Unique User Downloads Download Rankings  
 0%
Total:48
This week:0
All time:10,652
This week:24Up