Search code examples
google-search-appliance

GSA use connector for databases do not have metadata?


We are working on a GSA project. We are using GSA version 7.2 and Connector database adapter 3.2.4. That SQL as

SELECT EMPLOYEE_ID,
  FIRST_NAME,
  LAST_NAME,
  EMAIL,
  PHONE_NUMBER,
  HIRE_DATE,
  JOB_ID,
  SALARY,
  COMMISSION_PCT,
  MANAGER_ID,
  DEPARTMENT_ID
FROM HR.EMPLOYEES ;

How to write "Stylesheet for Serving Results" for show all metadata from SQL.


Solution

  • You must customize stylesheet as follow:

    `<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <html>
    <head>
    <xsl:for-each select="pland_connector"> <!-- name of connector -->
      <!-- now for every single field from the database you want to be able to filter upon or show in your result, add a meta-field -->
      <title><xsl:value-of select="LAST_NAME"/></title> <!-- don't forget the title -> that is the default title in the GSA result -->
      <meta name="EMPLOYEE_ID"><xsl:attribute name="content"><xsl:value-of select="EMPLOYEE_ID"/></xsl:attribute></meta> 
      <!-- mind the capital sensitivity of XML, dependend on the notation in you db view or table the value-of should be in capitals or not -->
      <meta name="LAST_NAME"><xsl:attribute name="content"><xsl:value-of select="LAST_NAME"/></xsl:attribute></meta>
      <meta name="FIRST_NAME"><xsl:attribute name="content"><xsl:value-of select="FIRST_NAME"/></xsl:attribute></meta>
      <meta name="EMAIL"><xsl:attribute name="content"><xsl:value-of select="EMAIL"/></xsl:attribute></meta>
      <meta name="PHONE_NUMBER"><xsl:attribute name="content"><xsl:value-of select="PHONE_NUMBER"/></xsl:attribute></meta>
      <!-- Etc..... -->
    
    </xsl:for-each>
    <!-- You can add static metadata to -->
    <meta name="test" content="Person"/>
    </head>
    <body>
    <!-- Just see what data you want in the content-field -->
    <xsl:for-each select="pland_connector"> <!-- Name of database -->
      <h1><xsl:value-of select="NAME"/></h1></br>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>`
    

    I think you will completed.