Class Schema


  • public final class Schema
    extends Object
    Contains information about the kinds of document Fields which are supported by the Index.

    
       // Get the searchService for the default namespace
       SearchService searchService = SearchServiceFactory.getSearchService();
    
       // Get the first page of indexes available and retrieve schemas
       GetResponse<Index> response = searchService.getIndexes(
           GetIndexesRequest.newBuilder().setSchemaFetched(true).build());
    
       // List out elements of Schema
       for (Index index : response) {
         Schema schema = index.getSchema();
         for (String fieldName : schema.getFieldNames()) {
            List<FieldType> typesForField = schema.getFieldTypes(fieldName);
         }
       }
     
    • Method Detail

      • getFieldNames

        public Set<String> getFieldNames()
        Returns:
        the set of field names supported in the schema
      • getFieldTypes

        public List<Field.FieldType> getFieldTypes​(String fieldName)
        Parameters:
        fieldName - the name of the field to return supported types
        Returns:
        a list of Field.FieldType supported for the given field name. The returned list will be empty if the schema has no field with the given name.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • newBuilder

        public static Schema.Builder newBuilder()
        Creates a schema builder.
        Returns:
        a new builder for creating a schema