vendredi 31 juillet 2015

ArangoDB search by string field

I want to do a simple search by text in a specific field of a specific collection in ArangonDB. Something like this ( in SQL ):

SELECT * FROM procedures WHERE procedures.name LIKE '%hemogram%'

I need to search in a string field of object ( document? ) that is part of an array that is a field of my actuall document:

[
  {
    "name": "Unimed",
    "procedures": [
      {
        "type": "Exames",
        "name": "Endoscopia"
      },
      {
        "type": "Exame",
        "name": "Hemograma"
      }
    ]
  }
]

I want to retrieve, for example, all procedures that name likes a "string", searching in all documents of my clinics collection.

I've been reading about fulltext indexes but I couldn't understand how to create or how to use them.

Any help would be great!

EDIT

I almost got what I wanted. My problem is now return just the information I want.

FOR clinic IN clinics
  FILTER LIKE(clinic.procedures[*].name, '%hemogram%', true)
  RETURN{
   clinic_name: clinic.name,
   procedure: clinic.procedures
  }

This returns to me all the procedures in a given clinic ( procedures is an array inside a clinic ) and not only the procedure which the field name is 'LIKE' my search string. How can I achieve this?

Aucun commentaire:

Enregistrer un commentaire