Field Mappings send your own WordPress data to your Opensolr Index: a brand stored in post meta, an ACF field, a taxonomy, a WooCommerce attribute. Once a field is in the index, you can turn it into a filter of your search page. The section is at the top of the Facet Mapping tab.
Add a mapping
- Open Settings > Opensolr Search, tab Facet Mapping.
- In WordPress Field, start typing: the list offers the post fields (
post_title,post_dateand the others), the meta keys of your posts (also the ones starting with an underscore, such as_price), the public taxonomies and, with WooCommerce, the product attributes (pa_...),featured_image_urlandgallery_image_urls. - In Solr Field Name, give the field a short name, for example
brand. - Pick the Solr Type. The plugin pre-selects the type that fits the values it found.
- Give it a Display Label, for example "Brand".
- Click + Add Field Mapping for more rows, then Save Facet Settings.
- Crawl or ingest your content again, so the new field reaches the index.
The types
The field in your index is the name plus the ending of its type: brand with String (single) becomes brand_s.
- String (single)
_s, the default, and String (multi-value)_sm. String (single, legacy)_ssis there for older setups. - Float (single)
_fand Float (multi-value)_fm, for prices and measures. - Integer (single)
_iand Integer (multi-value)_im, for counts and lengths in seconds. - Date (single)
_dtand Date (multi-value)_dtm.
Pick a multi-value type when a post can have several values, such as several tags or colours. What these endings mean in your index: Dynamic fields.
How the values reach your index
- Crawl: the plugin writes each value in the page head as a tag named
opensolr:plus the field, for exampleopensolr:brand_s. The Data Crawler reads it. A multi-value field gets one tag per value. - Push: Data Ingestion sends the value with the post.
A media ID becomes the address of the file, and an ACF image or file field sends its address.
Then use it
Once the field holds values in your index, it appears in the table below the mappings: Facet Configuration. It can also be the source of result pictures: Solr field for result image.
Facets
- Facets
- Field Mappings
- Facet Configuration