SearchSuggestionSpec.Builder


public final class SearchSuggestionSpec.Builder


Builder for objects.

Summary

Public constructors

Builder(@IntRange(from = 1) int maximumResultCount)

Creates an SearchSuggestionSpec.Builder object.

Public methods

@NonNull SearchSuggestionSpec.Builder
addFilterDocumentClasses(@NonNull Class[] documentClasses)

Adds a schema filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder

Adds the Schema names of given document classes to the Schema type filter of SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
addFilterDocumentIds(
    @NonNull String namespace,
    @NonNull String[] documentIds
)

Adds a document ID filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
addFilterDocumentIds(
    @NonNull String namespace,
    @NonNull Collection<String> documentIds
)

Adds a document ID filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
addFilterNamespaces(@NonNull String[] namespaces)

Adds a namespace filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder

Adds a namespace filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
addFilterProperties(
    @NonNull Class<Object> documentClass,
    @NonNull Collection<String> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
addFilterProperties(
    @NonNull String schema,
    @NonNull Collection<String> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
addFilterPropertyPaths(
    @NonNull Class<Object> documentClass,
    @NonNull Collection<PropertyPath> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
addFilterPropertyPaths(
    @NonNull String schema,
    @NonNull Collection<PropertyPath> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
addFilterSchemas(@NonNull String[] schemaTypes)

Adds a schema filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder

Adds a schema filter to SearchSuggestionSpec Entry.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_SEARCH_STRING_PARAMETERS)
addSearchStringParameters(@NonNull String[] searchStringParameters)

Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

@NonNull SearchSuggestionSpec.Builder
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_SEARCH_STRING_PARAMETERS)
addSearchStringParameters(@NonNull List<String> searchStringParameters)

Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

@NonNull SearchSuggestionSpec

Constructs a new SearchSpec from the contents of this builder.

@NonNull SearchSuggestionSpec.Builder
setRankingStrategy(int rankingStrategy)

Sets ranking strategy for suggestion results.

Public constructors

Builder

Added in 1.1.0-alpha07
public Builder(@IntRange(from = 1) int maximumResultCount)

Creates an SearchSuggestionSpec.Builder object.

Parameters
@IntRange(from = 1) int maximumResultCount

Sets the maximum number of suggestion in the returned object.

Public methods

addFilterDocumentClasses

public @NonNull SearchSuggestionSpec.Builder addFilterDocumentClasses(@NonNull Class[] documentClasses)

Adds a schema filter to SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified schema.

If unset, the query will search over all schema.

Merged list available from getFilterSchemas.

Parameters
@NonNull Class[] documentClasses

classes annotated with Document.

addFilterDocumentClasses

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec.Builder addFilterDocumentClasses(
    @NonNull Collection<Class<Object>> documentClasses
)

Adds the Schema names of given document classes to the Schema type filter of SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified schema.

If unset, the query will search over all schema.

Merged list available from getFilterSchemas.

Parameters
@NonNull Collection<Class<Object>> documentClasses

classes annotated with Document.

addFilterDocumentIds

public @NonNull SearchSuggestionSpec.Builder addFilterDocumentIds(
    @NonNull String namespace,
    @NonNull String[] documentIds
)

Adds a document ID filter to SearchSuggestionSpec Entry. Only search for suggestions in the given specified documents.

If unset, the query will search over all documents.

addFilterDocumentIds

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec.Builder addFilterDocumentIds(
    @NonNull String namespace,
    @NonNull Collection<String> documentIds
)

Adds a document ID filter to SearchSuggestionSpec Entry. Only search for suggestions in the given specified documents.

If unset, the query will search over all documents.

addFilterNamespaces

public @NonNull SearchSuggestionSpec.Builder addFilterNamespaces(@NonNull String[] namespaces)

Adds a namespace filter to SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified namespaces.

If unset, the query will search over all namespaces.

addFilterNamespaces

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec.Builder addFilterNamespaces(@NonNull Collection<String> namespaces)

Adds a namespace filter to SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified namespaces.

If unset, the query will search over all namespaces.

addFilterProperties

Added in 1.1.0-alpha07
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
public @NonNull SearchSuggestionSpec.Builder addFilterProperties(
    @NonNull Class<Object> documentClass,
    @NonNull Collection<String> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry. Only search for suggestions that has content under the specified property. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type.

If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be retrieved.

Parameters
@NonNull Class<Object> documentClass

class annotated with Document.

@NonNull Collection<String> propertyPaths

The String version of PropertyPath. A dot-delimited sequence of property names indicating which property in the document these snippets correspond to.

addFilterProperties

Added in 1.1.0-alpha07
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
public @NonNull SearchSuggestionSpec.Builder addFilterProperties(
    @NonNull String schema,
    @NonNull Collection<String> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry. Only search for suggestions that has content under the specified property. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type.

If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be retrieved.

Example properties: 'body', 'sender.name', 'sender.emailaddress', etc.

Parameters
@NonNull String schema

the AppSearchSchema that contains the target properties

@NonNull Collection<String> propertyPaths

The String version of PropertyPath. A dot-delimited sequence of property names indicating which property in the document these snippets correspond to.

addFilterPropertyPaths

Added in 1.1.0-alpha07
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
public @NonNull SearchSuggestionSpec.Builder addFilterPropertyPaths(
    @NonNull Class<Object> documentClass,
    @NonNull Collection<PropertyPath> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry. Only search for suggestions that has content under the specified property. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type.

If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be retrieved.

Parameters
@NonNull Class<Object> documentClass

class annotated with Document.

@NonNull Collection<PropertyPath> propertyPaths

The PropertyPath to search suggestion over

addFilterPropertyPaths

Added in 1.1.0-alpha07
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_PROPERTIES)
public @NonNull SearchSuggestionSpec.Builder addFilterPropertyPaths(
    @NonNull String schema,
    @NonNull Collection<PropertyPath> propertyPaths
)

Adds property paths for the specified type to the property filter of SearchSuggestionSpec Entry. Only search for suggestions that has content under the specified property. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type.

If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be retrieved.

Parameters
@NonNull String schema

the AppSearchSchema that contains the target properties

@NonNull Collection<PropertyPath> propertyPaths

The PropertyPath to search suggestion over

addFilterSchemas

public @NonNull SearchSuggestionSpec.Builder addFilterSchemas(@NonNull String[] schemaTypes)

Adds a schema filter to SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified schema.

If unset, the query will search over all schema.

addFilterSchemas

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec.Builder addFilterSchemas(@NonNull Collection<String> schemaTypes)

Adds a schema filter to SearchSuggestionSpec Entry. Only search for suggestions that has documents under the specified schema.

If unset, the query will search over all schema.

addSearchStringParameters

@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_SEARCH_STRING_PARAMETERS)
public @NonNull SearchSuggestionSpec.Builder addSearchStringParameters(@NonNull String[] searchStringParameters)

Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

See also
search

addSearchStringParameters

Added in 1.1.0-alpha07
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_SEARCH_STRING_PARAMETERS)
public @NonNull SearchSuggestionSpec.Builder addSearchStringParameters(@NonNull List<String> searchStringParameters)

Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

See also
search

build

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec build()

Constructs a new SearchSpec from the contents of this builder.

setRankingStrategy

Added in 1.1.0-alpha07
public @NonNull SearchSuggestionSpec.Builder setRankingStrategy(int rankingStrategy)

Sets ranking strategy for suggestion results.

The default value SUGGESTION_RANKING_STRATEGY_DOCUMENT_COUNT will be used if this method is never called.