Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 2.71 KB

README.md

File metadata and controls

69 lines (49 loc) · 2.71 KB

Solr Query Builder Build Status Scrutinizer Code Quality Latest Stable Version License

A simple PHP library to build Apache Solr queries

Features

  • Fluid query-builder API
  • Wildcard support
  • Fuzzy search
  • Integer- and string-range support
  • Fully unit-tested
  • Solr version support (3 & 4)

Installation

Use composer:

composer.phar require swiss-php-friends/solr-query-builder

Usage

The library provides a simple, fluid query builder. E.g.:

use SPF\SolrQueryBuilder\QueryBuilder;
use SPF\SolrQueryBuilder\Query\QueryInterface

$qb = new QueryBuilder;

// simple wildcard query
$query = $qb->select()
    ->where('text_en', 'foo')
    ->orWhere('text_en', 'bar', QueryInterface::WILDCARD_SURROUNDED)
    ->getQueryString();
    
// nesting
$query = $qb->select()
    ->nest()
        ->where('text_de', 'foo')
        ->andWhere('text_en', 'bar')
    ->endNest()
    ->orWhere('id', 2)
    ->getQueryString();

// value building (e.g. fuzzy-search or ranges)
$query = $qb->select()
    ->where('text_de', $qb->createFuzzySearchValue('foo', 0.7))
    ->orWhere('text_en', $qb->createStringRange('bar', 'baz'))
    ->orWhere('id', $qb->createNumericRange(10, 100))
    ->getQueryString();

Documentation

For a complete function reference see the API-Docs.

The tests also provide a good overview of the query builder and hot it works.

May the coverage-report provide you with some more information...

Contribution

You are very welcome to contribute. Report bugs and feature-requests to the GitHub Issue Tracking, or propose a PullRequest.

For contributions, please use the Symfony Coding Standard and write unit-tests.

Release Notes

See GitHub Releases