3
votes

Say, I have vertices with the property "text" and a fulltext index for this property.

In the arango 2.1.2 shell, I can query the vertices with

g._vertices.fulltext("text","my text value")

or db.v.fulltext("text","my text value")

But if I use blueprints-arangodb-graph-1.0.8, the request which the blueprint implementation fires looks like

http://{arangodb}/_db/testdb/_api/graph/test_graph/vertices

with the body:

{"batchSize":1,"count":false,"filter":{"properties":[{"key":"text","value":"my text value":"=="}]}}

This is extremely inefficient because it iterates over every vertex.

So, is it possible to do the query efficient in

  • aql
  • blueprints
  • and http interface?

Many thanks.

UPDATE: I found the simple fulltext query via HTTP

http://{arangodb}/_db/testdb/_api/simple/fulltext

and body:

{ "collection": "test_vertices", "attribute" : "text", "query" : "my text value" }

UPDATE-2 I found the AQL:

FOR v in FULLTEXT(test_vertices, 'text', 'my text value') RETURN v
1

1 Answers

2
votes

Let's say your collection is called "vertices" and your attribute is "text".

In AQL you can use "FULLTEXT" (see http://docs.arangodb.org/Aql/Operators.html):

arangosh [_system]> db._query("return FULLTEXT(vertices, 'text', 'hallo')").toArray()
[ 
  [ 
    { 
      "_id" : "vertices/268953710", 
      "_rev" : "268953710", 
      "_key" : "268953710", 
      "text" : "hallo hugo" 
    }, 
    { 
      "_id" : "vertices/269150318", 
      "_rev" : "269150318", 
      "_key" : "269150318", 
      "text" : "hallo emil" 
    }, 
    { 
      "_id" : "vertices/268757102", 
      "_rev" : "268757102", 
      "_key" : "268757102", 
      "text" : "hallo world" 
    } 
  ] 
]

For HTTP you can either use HTTP interface for AQL and the the above FULLTEXT function.

Alternatively you can use the "PUT /_api/simple/fulltext" endpoint and execute the fulltext search directly (see http://docs.arangodb.org/HttpSimpleQuery/README.html).