Document.DocumentProperty


@Documented
@Retention(value = RetentionPolicy.CLASS)
@Target(value = [ElementType.FIELD, ElementType.METHOD])
public annotation Document.DocumentProperty


Configures a member field of a class as a property known to AppSearch.

Field's data class is required to be annotated with Document.

Summary

Public methods

abstract boolean

Configures whether all fields in the nested document should be indexed.

abstract String[]

The list of properties in the nested document to index.

abstract boolean

Configures whether to inherit the indexable nested properties list from the Document's superclass type definition.

abstract String

The name of this property.

abstract boolean

Configures whether this property must be specified for the document to be valid.

Public methods

indexNestedProperties

Added in 1.1.0-alpha06
public abstract boolean indexNestedProperties()

Configures whether all fields in the nested document should be indexed.

If false, the nested document's properties are not indexed regardless of its own schema, unless indexableNestedPropertiesList is used to index a subset of properties from the nested document.

IllegalArgumentException will be thrown during setSchema if set to true and defining a non-empty list for indexableNestedPropertiesList

indexableNestedPropertiesList

Added in 1.1.0-alpha06
public abstract String[] indexableNestedPropertiesList()

The list of properties in the nested document to index. The property will be indexed according to its indexing configurations in the document's schema definition.

indexNestedProperties is required to be false if this list is non-empty. IllegalArgumentException will be thrown during setSchema if this condition is not met.

See also
AppSearchSchema.DocumentPropertyConfig.Builder

AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(Collection)

inheritIndexableNestedPropertiesFromSuperclass

Added in 1.1.0-alpha06
public abstract boolean inheritIndexableNestedPropertiesFromSuperclass()

Configures whether to inherit the indexable nested properties list from the Document's superclass type definition. When set to true, the indexable property paths will be a union of the paths specified in indexableNestedPropertiesList and any path specified in the document class's superclass or inherited interfaces. Effectively, this is a no-op if none of the document superclasses specify a path for this document property.

Ex. Consider the following Document classes:

class Person {
  = {"streetName", "zipcode"})
  Address livesAt;
}

class Artist extends Person {
  
    indexableNestedPropertiesList = {"country"},
    inheritIndexableNestedPropertiesFromSuperclass = true
  )
  Address livesAt;
}

By setting 'inheritIndexableNestedPropertiesFromSuperclass = true', Artist.livesAt inherits the indexable nested properties defined by its parent class's livesAt field (Person.livesAt) and indexes all three fields: {streetName, zipCode, country}

name

Added in 1.1.0-alpha06
public abstract String name()

The name of this property. This string is used to query against this property.

If not specified, the name of the field in the code will be used instead.

required

Added in 1.1.0-alpha06
public abstract boolean required()

Configures whether this property must be specified for the document to be valid.

This attribute does not apply to properties of a repeated type (e.g. a list).

Please make sure you understand the consequences of required fields on schema migration before setting this attribute to true.