makinacorpus/php-lucene-query

Name: php-lucene-query

Owner: Makina Corpus

Description: Minimalistic, feature-rich, PHP Lucene syntax query builder

Created: 2016-06-29 13:16:29.0

Updated: 2017-12-27 00:58:02.0

Pushed: 2017-09-26 16:38:44.0

Homepage: null

Size: 12

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Minimalistic, feature-rich, PHP Lucene syntax query builder

This is a very small piece of API that brings a query builder for building Lucene queries; use cases are numerous, the two most obvious ones being Elastic Search and Apache SolR.

Examples

new MakinaCorpus\Lucene\Query;

ry = new Query();

ry
->createTermCollection(Query::OP_OR)
->add("foo")
->add("bar")


ry
->createDateRange()
->setInclusive()
->setRange('1983-03-22', new \DateTime())


ry
->matchTerm('some_field', 'some value', null, 0.8)
->matchTerm('other_field', 'some_other_value', 1.3)

Should give you the following query:


(foo OR bar)
AND my_date_field:["1983\-03\-22T00\:00\:00\+0000" TO "2016\-06\-29T13\:10\:20\+0000"]
AND some_field:"some value"~0.8
AND other_field:some_other_value^1.3

Current status

This API is in use in various projects for now almost 10 years, although this version being a full refactor (mostly classes being renamed) that now runs in production for 6 months.

It's probably not bug free, and lacks some testing, yet until now it works.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.