orientechnologies / orientjs

The official fast, lightweight node.js client for OrientDB
http://orientdb.com
Other
326 stars 68 forks source link

Query lucene fulltext index #393

Open alexmm11 opened 5 years ago

alexmm11 commented 5 years ago

Hi, the lucene fulltext docs explains how to query a field using search_class in the form:

search_class("field:value*") = true

For instance:

SELECT FROM City WHERE SEARCH_CLASS("+name:cas*  +description:beautiful") = true

So i'm wondering if is possible do the query using ":" to include the string parameter value in the params object of the query, just like:

session.query("select from OUser where name = :name", {params: { name: "admin" }})

Instead of using something like:

`SELECT FROM City WHERE SEARCH_CLASS("+name:${val1}*  +description:${val2}") = true`

I tried like this :point_down: ... but didn't work :open_mouth: :disappointed:

session.query(
  'select from City where search_class("+name: :val1 *  +description: :val2") = true',
  {
    params: {
      val1: "name",
      val2: "beautiful"
    }
  }
);
wolf4ood commented 5 years ago

Hi @alexmm11

i think they cannot work as today. the searchClass takes a string and it does not apply parameters.

So this one will be the query passed to lucene "+name: :val1 * +description: :val2"

Let me check if we can find a way

Thanks

wolf4ood commented 5 years ago

Probably for now the best way is to do

`SELECT FROM City WHERE SEARCH_CLASS(:query) = true`

and use only 1 param query with +name:${val1}* +description:${val2} the lucene query content