Written by The Jahia Team
 
Developers
   Estimated reading time:

Indexed custom properties are automatically indexed as text or keyword, enabling you to use them for facets.
To use a property as a facet:

  1. Modify the augmented search configuration by adding the definition types you want to map and index.
    1. In Jahia Tools, navigate to Administration and Guidance>OSGi console.
    2. Select OSGI>Configuration and edit values for the org.jahia.modules.augmentedsearch module.
    3. Edit the following org.jahia.modules.augmentedsearch.content.indexedMainResourceTypes and org.jahia.modules.augmentedsearch.content.mappedNodeTypes properties. The following example shows adding  the jacademix:document definition type.

      jahia-tools-as.png

  2. In Jahia, reindex your data.
    1. In Administration, select Configuration>Augmented search management.
    2. Click Index the content in the main window. Then click Save.
      augmented-search-reindexed.png

Now your data can be used in your queries. The following example show how to make a jacademix:document mixin a main resource to be searched. The example also shows how to map it so that the author property can be used for facets.



{
  jcr {
    searches(siteKey: "academy", language: "en", workspace: LIVE) {
      search(q: "cluster", limit: 20, offset: 0, 
        filter: {nodeType: {type: "jacademix:document"}}, 
        facets: {
          term: [
          {field:"author.keyword", minDocCount:1}]}) {
        totalHits
        took
        facets {
          field
          type
          data {
            ... on TermValue {
              count
              value
            }            
          }
        }
        hits {
          id
          link
          displayableName
          excerpt
          score
          lastModified
          lastModifiedBy
          createdBy
          created
        }
      }
    }
  }
}