Adding custom fields
Last updated
Was this helpful?
Last updated
Was this helpful?
The crawler extracts metadata from each page and condenses it into a standard set of fields to be added to the search index.
The crawler uses page metadata and content to construct a standardized set of fields:
URL (url
). The full URL of the page
Title (title
). The meta-title of the page
Image (image
). URL for the page image
Language (lang
). Language of the page content (en
, fr
, de
, ...)
Description (description
). The meta description of the page
Keywords (keywords
). List of keywords for the page
Modified Time (modified_time
). The time when the page was last modified
Published Time (published_time
). The time when the page was first published
Headings (headings
). List of headings from the body of the page
To see a full list of the fields we crawl and their associated HTML markup, visit page.
The page <body>
is summarised to provide a more concise base for searching. This process discards text inside <head>
, <script>
, <header>
and <footer>
elements.
Fields derived from the URL are also included for common queries (e.g. limiting to a domain or particular sub-URL structure of a site):
Domain (domain
). The domain of the URL
First directory (dir1
). The first directory of the URL, or empty if none
Secondary directory (dir2
). The second directory of the URL, or empty if none
In addition to the above, the following metadata is also extracted if available:
All meta tags within head
OpenGraph tags
Custom SJ tags
Body content (<body>
)
Add a schema field (e.g. authors
) and select the desired schema field type.
Add custom meta tags to your site (see below).
Re-crawl all domains so all records are updated.
Filters and facets often use additional fields to provide better searching and filtering capabilities. For example, a news site might want to filter by topic or a documentation site by version.
Custom meta tags allow you to add those additional fields to your records. Meta tags are defined in HTML by adding data
attributes to elements. To avoid name clashes with other systems, data attributes must contain the prefix data-sj-
.
<head>
elementsBy default the crawler reads <meta>
tags within <head>
, but only keeps standard fields (title, description, keywords, etc). Add a data-sj-field="fieldname"
attribute to override this behaviour and create a custom field from the meta tag's content
attribute. This example shows an otherwise ignored <meta>
tag being converted into a custom field fieldname="fieldvalue"
:
<body>
elementsTo capture data already rendered within an element, add data-sj-field="fieldname"
to it:
This will set custom field random="This text is the value"
.
If you don't want the data rendered on the page, then you can also set the field value using the data attribute.
It is possible to add a list of values by repeating the same tag multiple times. You just need to ensure that the schema field type is a 'List of String/Integers/etc'.
In the example above, the strings "Art, Biology, Chemistry" will be stored as a list against the field topics
.
Note: If you have multiple meta tags on your page for a specific field but the schema field type is not a list, we will not index that webpage.
Localization
Problem: I have very locally targeted content and wish to recommend local content based on my site visitor location. Solution: On each "locally" targeted content page, add two pieces of meta information as follows. e.g.
In the above case, the prefix data-sj-field indicates this is information specific to the page. So data-sj-field="lat"
indicates this page has a property called "lat" with corresponding value -33.867487.
Processed metadata is the metadata that is stored in the index. Raw metadata is read by the crawler, but may not be indexed in the search index. An example of raw metadata is links on a webpage that may be useful for the crawler to find linked pages, but do not need to be recorded in the search index.
To test what content of a webpage is indexed, use our .
Crawl a page containing the custom field via the . Use the to check that the additional field was indexed correctly.