2017 © Pedro Peláez
 

library search-bundle

An agnostic search bundle.

image

naroga/search-bundle

An agnostic search bundle.

  • Thursday, February 11, 2016
  • by naroga
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Travis, (*1)

Naroga's Search Bundle

This is a search bundle, developed for exclusive usage of DistantJobHire., (*2)

Requirements

This project makes use of some cool PHP 7.0 features (such as the Null Coalesce operator, Spaceship operator, scalar typehints, function return typehints and others). It also uses Symfony3, which means it shares its requirements. Additionally, you'll need the php-curl extension., (*3)

Installation

To install this package, require it using composer:, (*4)

$ composer require naroga/search-bundle dev-master

Usage

Indexing a document:, (*5)

$ php bin/console search:add <filename>
File written successfully with ID <ID>

This indexes the file content., (*6)

Deleting a document:, (*7)

$ php bin/console search:delete <id>
<#> entries deleted successfully.

This deletes an indexed document., (*8)

Searching for a document:, (*9)

$php bin/console search:search <expression>
Found <#> results:
...

This searches for documents containing matches from the provided expression., (*10)

Unit testing

Clone this repository, install the dependencies using composer install and run phpunit., (*11)

Switching Search Engines

To switch to another Search Engine (let's use MyCustomSearchEngine as an example), you'll have to create a new bundle., (*12)

$ php bin/console generate:bundle

Now, define this bundle as a parent of NarogaSearchBundle:, (*13)

#MyCustomSearchBundle.php
class MyCustomSearchBundle extends Bundle
{
    public function getParent()
    {
        return 'NarogaSearchBundle';
    }
}

Now, create a new MyCustomSearchEngine class that implements EngineInterface:, (*14)

class MyCustomSearchEngine implements EngineInterface
{
    public function add(string $name, string $content)
    {
        // TODO: Implement add() method.
    }

    public function search(string $expression) : array
    {
        // TODO: Implement search() method.
    }

    public function delete(string $id)
    {
        // TODO: Implement delete() method.
    }
}

In your services.yml file, define your search engine as a service:, (*15)

services:
    mycustomengine.engine:
        class: My\Class\Path
        arguments: [ "here_come_your_dependencies" ]

Still in the services section, override the naroga.search service:, (*16)

    naroga.search:
        class: Naroga\SearchBundle\Search\Search
        arguments: [ "@mycustomengine.engine" ] #pass your custom service here as a parameter.

Now you're good to go!, (*17)

License

This project is proprietary and thus cannot be used, copied, modified or distributed without explicit written consent from the owner (DistantJobHire)., (*18)

The Versions

11/02 2016

dev-master

9999999-dev

An agnostic search bundle.

  Sources   Download

proprietary

The Requires

 

The Development Requires

by Pedro Cordeiro