2017 © Pedro PelĆ”ez
 

library search-engine

Component that tries to help you get the Query part in CQRS right

image

gnugat/search-engine

Component that tries to help you get the Query part in CQRS right

  • Thursday, May 19, 2016
  • by gnupat
  • Repository
  • 2 Watchers
  • 3 Stars
  • 81 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Search Engine SensioLabsInsight Build Status

A Proof Of Concept demonstrating how to handle Interrogatory Messages (Query in CQRS)., (*1)

The Command / Query Responsibility Segregation principle explains that Imperative and Interrogatory messages shouldn't be mixed together., (*2)

Note: Learn more about the different messaging flavours., (*3)

Usually imperative messages are handled using the CommandBus pattern, which leaves us with the following question: how Interrogatory Messages should be handled?, (*4)

This component tries to explore one of the possible answers: a SearchEngine that would try to return results matching a given criteria., (*5)

Caution: this component does not provide actual SearchEngine features, if you're looking for one you should rather have a look at ElasticSearch, Solr, etc., (*6)

Installation

Download SearchEngine using Composer:, (*7)

composer require gnugat/search-engine:^0.3

You'll also need to choose one of the following implementations:, (*8)

Other possible implementations: PDO, Doctrine DBAL, Doctrine ORM, etc. In the tests directory you'll find an Array implementation example., (*9)

More information about implementations, (*10)

Usage

SearchEngine expects a Criteria object which describes:, (*11)

  • the resource to query
  • relations to embed
  • filters to apply
  • orderings instructions
  • pagination parameters

It can be built from query parameters as follow:, (*12)

// ...
$criteria = $criteriaFactory->fromQueryParameters('blog', [
    // Filters
    'title' => 'IG',
    'author_ids' => '1,3',

    // Pagination
    'page' => '2',
    'per_page' => '3',

    // Ordering
    'sort' => 'author_id,-title',

    // Relation embeding
    'embed' => 'author',
]);
print_r(iterator_to_array(
    $searchEngine
        ->match($criteria)
        ->take(
            $criteria->paginating->offset,
            $criteria->paginating->itemsPerPage
        )
        ->getIterator()
));

In a web context, this $queryParameters array could actually be $_GET, corresponding to the following URL:, (*13)

/v1/blogs?title=IG&author_ids=1,2&page=1&per_page=3&sort=author_id,-title&embed=author

The result could be the following:, (*14)

[
    'items' => [
        [
            'id' => 1,
            'title' => 'Big Title',
            'author_id' => 1,
        ],
        [
            'id' => 2,
            'title' => 'Big Header',
            'author_id' => 2,
        ],
    ],
    'page' => [
        'current_page' => 1,
        'per_page' => 3,
        'total_elements' => 2,
        'total_pages' => 1,
    ],
]

Further documentation

You can see the current and past versions using one of the following:, (*15)

You can find more documentation at the following links:, (*16)

Next readings:, (*17)

The Versions

19/05 2016

dev-master

9999999-dev http://gnugat.github.io/search-engine

Component that tries to help you get the Query part in CQRS right

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

19/05 2016

v0.3.0

0.3.0.0 http://gnugat.github.io/search-engine

Component that tries to help you get the Query part in CQRS right

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

06/12 2015

v0.2.3

0.2.3.0 http://gnugat.github.io/search-engine

A POC library to handle interrogatory messages

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

24/08 2015

v0.2.2

0.2.2.0 http://gnugat.github.io/search-engine

A POC library to handle interrogatory messages

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

21/08 2015

v0.2.1

0.2.1.0 http://gnugat.github.io/search-engine

A POC library to handle interrogatory messages

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

21/08 2015

v0.2.0

0.2.0.0 http://gnugat.github.io/search-engine

A POC library to handle interrogatory messages

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message

21/08 2015

v0.1.0

0.1.0.0 http://gnugat.github.io/search-engine

A POC library to handle interrogatory messages

  Sources   Download

MIT

The Requires

 

The Development Requires

cqrs query bus search engine interrogatory message