Skip to main content

Full-text search in the inventory

· 4 min read
Koen Van Daele
Onroerend Erfgoed

Since May 13, a brand new inventory has been live at https://inventaris.onroerenderfgoed.be. Last time (From searching to finding on the new inventory) we covered some general principles; today we dig into full-text search. We use heritage objects as our example, but our other modules support the same syntax.

warning

Because the new inventory is still fresh, small shifts may still occur.

Full-text search works like a major web search engine: you're after a fairly specific object or document, and the search engine tries to put the best match on top. Search for Gravensteen and you get the most "Gravensteen-like" object first.

Several factors determine what counts as most relevant: the more often your search term appears in an object, the more relevant; the smaller the field it appears in, the more relevant; and the more often the term appears across all objects overall, the less relevant. Certain fields also weigh more heavily than others — a title counts for more than the body text of a record. Search for Gravensteen and an object titled that way outranks one where the term appears once in the text.

Type Gravensteen into the Algemeen ("general") field of the heritage objects search form and you get https://inventaris.onroerenderfgoed.be/erfgoedobjecten?tekst=gravensteen, with the Gravensteen in Ghent on top. Case doesn't matter here.

Want to know specifically about the Gravensteen in Aalst? Search Gravensteen Aalst and you get only 2 results: objects containing both Gravensteen and Aalst. By default, each word is treated as a separate term combined with AND — written as +, so Gravensteen Aalst equals Gravensteen+Aalst. Prefer either one or the other? Use the OR operator, the pipe character |: Gravensteen|Aalst. The third operator is NOT, a - sign: Gravensteen -Aalst gives you everything with Gravensteen but not Aalst.

By default the search engine splits your query on spaces. Search Grote Markt Aalst and you get quite a few results, including, right at the bottom, Paviljoen De Notelaer — the words grote, markt and aalst do appear, just not next to each other. To search for the exact phrase, use quotes: "Grote Markt" Aalst searches for two terms instead of three, and returns fewer, more relevant results.

For more complex combinations, use parentheses to control operator precedence. Search vismarkt brugge gent and you get objects containing all three terms — not what you meant. vismarkt + brugge | gent then returns far too many results, because operators have a fixed precedence. The fix: group with parentheses, vismarkt + (brugge|gent), to find records about the fish market that also mention Bruges or Ghent.

You can also search on part of a word with a postfix wildcard: gedenk* matches gedenksteen, gedenkplaat and similar words. This only works at the end of a term — *linde won't match herdenkingslinde. You can combine all of this: visgraat* (oost-vlaanderen|west-vlaanderen) -brugge finds objects with a word starting with visgraat, in East or West Flanders, but not in Bruges.

Which fields are actually searched in full text, and in what order of importance? The text, the text's title, the short description (shown in a search result), province, municipality, sub-municipality and street names, thesaurus terms, and the object's own name. We show every object containing your term, unless there are more than 10,000 (the maximum number of results).

In short, these are the operators you can use:

  • Multiple terms are implicitly combined with AND; make it explicit with +
  • Combine with OR using |
  • Exclude a term with NOT using -
  • Turn multiple words into one term with quotes "
  • Control operator precedence with parentheses ()
  • Search by prefix with a postfix wildcard *

Happy searching! Questions about search are always welcome — get in touch.