Download the PHP package andydefer/inverted-index-search without Composer

On this page you can find all versions of the php package andydefer/inverted-index-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package inverted-index-search

InvertedIndexSearch - Documentation complète

PHP Version Package

📖 Table des matières

  1. Introduction
  2. Installation
  3. Architecture
  4. Composants principaux
    • InvertedIndexSearchService
    • InvertedIndexQueryBuilder
    • InvertedIndexExpressionEvaluator
  5. Opérateurs booléens
  6. Cas d'usage réels
  7. Performance
  8. API Reference

Introduction

InvertedIndexSearch est une bibliothèque PHP qui étend les capacités de l'index inversé d'AlgoKIT en fournissant un moteur de recherche complet avec opérateurs booléens. Elle permet d'effectuer des recherches plein texte complexes avec une syntaxe intuitive et des performances optimales.

Philosophie

Problème Solution classique Solution InvertedIndexSearch
Recherche plein texte Scanner tous les documents (lent) Index inversé (O(1) par terme)
Requêtes booléennes Implémentation manuelle Opérateurs AND, OR, NOT, XOR
Requêtes complexes Construction manuelle d'expressions QueryBuilder fluent
Expressions imbriquées Parsing complexe Évaluateur avec support des parenthèses

Les 3 composants clés

Composant Rôle Utilisation
SearchService API principale de recherche Méthodes pratiques (and, or, not, xor)
QueryBuilder Construction fluent de requêtes Conditions et groupes imbriqués
ExpressionEvaluator Évaluation d'expressions Parsing et évaluation booléenne

Installation

Prérequis


Architecture

Dépendances

Structure des composants


Composants principaux

InvertedIndexSearchService

Service principal offrant une API intuitive pour les recherches booléennes.

Méthodes principales :

Méthode Description Exemple
and(array $tokens) Tous les tokens doivent être présents $search->and(['php', 'laravel'])
or(array $tokens) Au moins un token doit être présent $search->or(['php', 'python'])
not(string $include, string $exclude) Inclure un token, exclure un autre $search->not('php', 'python')
xor(string $term1, string $term2) Exactement un des deux tokens $search->xor('php', 'python')
expression(string $expr) Expression booléenne complexe $search->expression('(php OR python) AND laravel')
andWithLimit(array $tokens, int $limit) AND avec limite $search->andWithLimit(['php'], 10)
orWithLimit(array $tokens, int $limit) OR avec limite $search->orWithLimit(['php'], 10)
query() Retourne le QueryBuilder $search->query()->where('php')->get()

Exemple d'utilisation :

InvertedIndexQueryBuilder

Constructeur fluent pour des requêtes complexes.

Méthodes :

Méthode Description Exemple
where(string $token) Condition AND ->where('php')
orWhere(string $token) Condition OR ->orWhere('python')
whereNot(string $token) Exclusion ->whereNot('java')
whereGroup(callable $callback) Groupe AND ->whereGroup(fn($q) => $q->where('laravel')->orWhere('vuejs'))
orWhereGroup(callable $callback) Groupe OR ->orWhereGroup(fn($q) => $q->where('php')->where('laravel'))
get() Exécute la requête ->get()
reset() Réinitialise le builder ->reset()
toExpression() Génère l'expression ->toExpression()

Exemple d'utilisation :

InvertedIndexExpressionEvaluator

Évaluateur d'expressions booléennes avec support des parenthèses.

Syntaxe supportée :

Opérateur Description Priorité Exemple
NOT Négation (unaire) 4 NOT python
XOR Ou exclusif 3 php XOR python
AND Et logique 2 php AND laravel
OR Ou logique 1 php OR python
() Regroupement - (php OR python) AND laravel

Exemple d'utilisation :


Opérateurs booléens

AND (Et logique)

Documents contenant tous les tokens.

OR (Ou logique)

Documents contenant au moins un token.

NOT (Négation)

Documents contenant le premier token mais pas le second.

XOR (Ou exclusif)

Documents contenant exactement un des deux tokens.


Cas d'usage réels

1. Moteur de recherche de blog

Problème : Implémenter un moteur de recherche d'articles avec filtres par tags, catégories et exclusions.

2. Recherche de produits e-commerce

Problème : Rechercher des produits avec filtres multiples et alternatives.

3. Analyse de logs avec filtres

Problème : Analyser des logs d'application avec des filtres complexes.

4. API de recherche dynamique

Problème : Exposer une API de recherche où les utilisateurs peuvent utiliser des opérateurs booléens.

5. Système de recommandation de tags

Problème : Recommander des tags pertinents basés sur une combinaison de tags existants.


Performance

Complexité algorithmique

Opération Complexité Détails
AND (2 tokens) O(a + b) Intersection de deux ensembles
AND (n tokens) O(n × m) Intersection séquentielle
OR (n tokens) O(n × m) Union et déduplication
NOT O(a + b) Différence d'ensembles
XOR O(a + b) Différences symétriques
Expression O(n × m) Dépend de la complexité

Optimisations

Comparatif

Structure Mémoire Performance Précision
InvertedIndexSearch Moyenne Rapide (O(1) par terme) 100%
Recherche naïve Élevée Lent (O(n)) 100%
Base de données SQL Élevée Moyen (indexes) 100%

API Reference

Services

Interfaces

Enums

Collections


License

MIT © Andy Defer


All versions of inverted-index-search with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
andydefer/algo-kit Version ^0.9.30
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andydefer/inverted-index-search contains the following files

Loading the files please wait ...