Searching Full-text with ArangoSearch

Search for tokens in full-text that can occur in any order

Full-text strings can be tokenized by text Analyzers so that each token (usually a word) gets indexed separately. Subsequently, it becomes possible to search for individual tokens. This is also possible with arrays of strings, where each element is one token (or multiple, additionally tokenized by a text Analyzer).

There are two ways to search for tokens:

  • Token search: The tokens can occur in any order. The words you search for merely need to be contained in the source string somehow.
  • Phrase search: The order of the tokens needs to match the query. This allows you to search for partial or full sentences.

Token search is covered below. For phrase search see Phrase and Proximity Search.

Dataset: IMDB movie dataset

View definition:

  1. {
  2. "links": {
  3. "imdb_vertices": {
  4. "fields": {
  5. "description": {
  6. "analyzers": [
  7. "text_en"
  8. ]
  9. }
  10. }
  11. }
  12. }
  13. }

AQL Queries:

Search for movies with dinosaur or park (or both) in their description:

  1. FOR doc IN imdb
  2. SEARCH ANALYZER(doc.description IN TOKENS("dinosaur park", "text_en"), "text_en")
  3. RETURN {
  4. title: doc.title,
  5. description: doc.description
  6. }
titledescription
Alone in the Wilderness… the Aleutian Peninsula, in what is now Lake Clark National Park. …
Madagascar Collection… The plot follows the adventures of story of four Central Park Zoo animals …
Sea Monsters: A Prehistoric AdventureJourney 80 million years back in time to an age when mighty dinosaurs dominated the land …
Land of the Lost… their only ally in a world full of dinosaurs and other fantastic creatures.

Search for movies with both dinosaur and park in their description:

  1. FOR doc IN imdb
  2. SEARCH ANALYZER(TOKENS("dinosaur park", "text_en") ALL == doc.description , "text_en")
  3. RETURN {
  4. title: doc.title,
  5. description: doc.description
  6. }
titledescription
Jurassic Park Series… the Jurassic Park films. This trilogy of films brings all our childhood fantasies to life with dinosaurs
Jurassic ParkA wealthy entrepreneur secretly creates a theme park featuring living dinosaurs
The Lost World: Jurassic ParkFour years after Jurassic Park’s genetically bred dinosaurs ran amok …
Cesta do pravěku… Four young boys visit a dinosaur exhibit … They then row out onto Central Park Lake …

The results will be the same if you use park dinosaur as search terms, as the tokens can be ordered arbitrarily.