2017 © Pedro Peláez
 

library query-translator

Query Translator is a search query translator with AST representation

image

netgen/query-translator

Query Translator is a search query translator with AST representation

  • Wednesday, April 4, 2018
  • by Netgen
  • Repository
  • 8 Watchers
  • 32 Stars
  • 50,142 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 5 Open issues
  • 9 Versions
  • 34 % Grown

The README.md

Query Translator

Build Status Code Coverage Downloads Latest stable License PHP, (*1)

Query Translator takes a search string as user input and converts it into something a search backend can understand. Technically, it's a search query translator with abstract syntax tree representation. From the produced syntax tree, translation target can be anything you need. Usually it's a search backend, like Solr and Elasticsearch, or a database abstraction layer., (*2)

A set of interfaces for implementing a language processor is provided, with a single implemented language named Galach. Galach implements a syntax that is based on what seems to be the unofficial standard for search query as user input. Quick cheat sheet:, (*3)

word "phrase" (group) +mandatory -prohibited AND && OR || NOT ! #tag @user domain:term, (*4)

Error handling

User input means you have to expect errors and handle them gracefully. Because of that, the parser is completely resistant to errors. Syntax tree will contain detailed information about corrections applied to make sense of the user input. This can be useful to clean up the input or implement rich input interface, with features like suggestions, syntax highlighting and error feedback., (*5)

Customization

The implementation was made with customization in mind. You can change the special characters which will be used as part of the syntax, pick out elements of the language you want to use, implement your own term clauses, or change how the syntax tree is converted to the target output., (*6)

Some use cases

  • User-level query language on top of your search backend
  • Common query language on top of different search backends
  • Control over options of the query language that is already provided by the search backend
  • Better error handling than provided by the search backend
  • Analysis and manipulation of the query before sending to the backend
  • Customized query language (while remaining within the base syntax)
  • Implementing rich input interface (with suggestions, syntax highlighting, error feedback)

Note: This implementation is intended as a library, meaning it doesn't try to solve specific use cases for query translation. Instead, it's meant to be a base that you can use in implementing such a use case., (*7)

How to use

First add the library to your project:, (*8)

composer require netgen/query-translator:^1.0

After that, make use of the features provided out of the box. If those are not enough, use extension points to customize various parts of the translator to fit your needs. See Galach documentation to find out more., (*9)

Run the demo

Demo is available as a separate repository at netgen/query-translator-demo., (*10)

Steps for running the demo:, (*11)

  1. Create the demo project using composer composer create-project netgen/query-translator-demo
  2. Position into the demo project directory cd query-translator-demo
  3. Start the web server with src as the document root php -S localhost:8005 -t src
  4. Open http://localhost:8005 in your browser Query Translator demo

The Versions

04/04 2018

dev-master

9999999-dev https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ^5.6||^7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

02/04 2018

dev-fix-domains-text

dev-fix-domains-text https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ^5.6||^7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

01/04 2018

dev-fix-domains-dot

dev-fix-domains-dot https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

30/03 2018

dev-feature_phpunit_7

dev-feature_phpunit_7 https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

01/12 2017

1.0.2

1.0.2.0 https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

29/11 2017

v102.x-dev

102.9999999.9999999.9999999-dev https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

01/07 2017

1.0.1

1.0.1.0 https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

21/06 2017

1.0.0

1.0.0.0 https://github.com/netgen/query-translator

Query Translator is a search query translator with AST representation

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Petar Španja

parser search elasticsearch generator query translator tokenizer solr ast edismax

23/03 2017

0.9.0

0.9.0.0

Query Translator is a search query translator with AST producing parser

  Sources   Download

MIT

The Development Requires

by Petar Španja

parser search generator query translator tokenizer ast