orientjs icon indicating copy to clipboard operation
orientjs copied to clipboard

Query lucene fulltext index

Open alexmm11 opened this issue 6 years ago • 2 comments

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"
    }
  }
);

alexmm11 avatar Oct 01 '19 09:10 alexmm11

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 avatar Oct 18 '19 12:10 wolf4ood

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

wolf4ood avatar Oct 18 '19 12:10 wolf4ood