2

At the moment I am using a simple full-text search with against/match of full phrase typed by the user. The idea is to allow user type a search request using the following connectors:

AND, OR, NOT
"" - exact match
() - grouping terms
* - single letter wildcard
! - root expander
/n - terms within n words of each other
/s - terms within same sentence of each other
/p - terms within the same paragraph

All these connectors will work as boolean operators. The task contains two parts:
1. to parse the string typed by the user (with the possible syntax errors)
2. build the SQL query

The exact same search works here - https://casetext.com/search

Also, I'm wondering if it will be easier to move to Lucena/Solr or Elasticsearch which have build-in parsers but still not the same what I need?

I saw already this parsing user-typed Full Text Search queries into WHERE clause of MySQL using PHP but it's not giving any answers

And I saw these packages:
https://packagist.org/packages/pecee/boolean-query-parser - basic syntax supported
https://packagist.org/packages/gdbots/query-parser - more sophisticated but not covering last 4 connectors from my list

slavkovl
  • 21
  • 6
  • Please [edit] your question to clarify. Are you using MySQL's FULLTEXT search in Boolean mode? https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html That offers a bit of a search language. Is your task to translate your search language into that one? – O. Jones Jun 27 '19 at 12:24
  • Thanks. I have edited the post. The thing is that the user can make a mistake in his search string request. And the parser should be able to deal with that also. – slavkovl Jun 27 '19 at 12:58

0 Answers0