你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

SearchField Class

  • java.lang.Object
    • com.azure.search.documents.indexes.models.SearchField

Implements

public final class SearchField
implements JsonSerializable<SearchField>

Represents a field in an index definition, which describes the name, data type, and search behavior of a field.

Constructor Summary

Constructor Description
SearchField(String name, SearchFieldDataType type)

Creates an instance of SearchField class.

Method Summary

Modifier and Type Method and Description
static SearchField fromJson(JsonReader jsonReader)

Reads an instance of SearchField from the JsonReader.

LexicalAnalyzerName getAnalyzerName()

Get the analyzerName property: The name of the analyzer to use for the field.

List<SearchField> getFields()

Get the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType).

LexicalAnalyzerName getIndexAnalyzerName()

Get the indexAnalyzerName property: The name of the analyzer used at indexing time for the field.

String getName()

Get the name property: The name of the field, which must be unique within the fields collection of the index or parent field.

LexicalAnalyzerName getSearchAnalyzerName()

Get the searchAnalyzerName property: The name of the analyzer used at search time for the field.

List<String> getSynonymMapNames()

Get the synonymMapNames property: A list of the names of synonym maps to associate with this field.

SearchFieldDataType getType()

Get the type property: The data type of the field.

VectorEncodingFormat getVectorEncodingFormat()

Get the vectorEncodingFormat property: The encoding format to interpret the field contents.

Integer getVectorSearchDimensions()

Get the vectorSearchDimensions property: The dimensionality of the vector field.

String getVectorSearchProfileName()

Get the vectorSearchProfileName property: The name of the vector search profile that specifies the algorithm and vectorizer to use when searching the vector field.

Boolean isFacetable()

Get the facetable property: A value indicating whether to enable the field to be referenced in facet queries.

Boolean isFilterable()

Get the filterable property: A value indicating whether to enable the field to be referenced in $filter queries.

Boolean isHidden()

Get the hidden property: A value indicating whether the field will be returned in a search result.

Boolean isKey()

Get the key property: A value indicating whether the field uniquely identifies documents in the index.

Boolean isSearchable()

Get the searchable property: A value indicating whether the field is full-text searchable.

Boolean isSortable()

Get the sortable property: A value indicating whether to enable the field to be referenced in $orderby expressions.

Boolean isStored()

Get the stored property: An immutable value indicating whether the field will be persisted separately on disk to be returned in a search result.

SearchField setAnalyzerName(LexicalAnalyzerName analyzerName)

Set the analyzerName property: The name of the analyzer to use for the field.

SearchField setFacetable(Boolean facetable)

Set the facetable property: A value indicating whether to enable the field to be referenced in facet queries.

SearchField setFields(SearchField[] fields)

Set the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType).

SearchField setFields(List<SearchField> fields)

Set the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType).

SearchField setFilterable(Boolean filterable)

Set the filterable property: A value indicating whether to enable the field to be referenced in $filter queries.

SearchField setHidden(Boolean hidden)

Set the hidden property: A value indicating whether the field will be returned in a search result.

SearchField setIndexAnalyzerName(LexicalAnalyzerName indexAnalyzerName)

Set the indexAnalyzerName property: The name of the analyzer used at indexing time for the field.

SearchField setKey(Boolean key)

Set the key property: A value indicating whether the field uniquely identifies documents in the index.

SearchField setSearchAnalyzerName(LexicalAnalyzerName searchAnalyzerName)

Set the searchAnalyzerName property: The name of the analyzer used at search time for the field.

SearchField setSearchable(Boolean searchable)

Set the searchable property: A value indicating whether the field is full-text searchable.

SearchField setSortable(Boolean sortable)

Set the sortable property: A value indicating whether to enable the field to be referenced in $orderby expressions.

SearchField setStored(Boolean stored)

Set the stored property: An immutable value indicating whether the field will be persisted separately on disk to be returned in a search result.

SearchField setSynonymMapNames(String[] synonymMapNames)

Set the synonymMapNames property: A list of the names of synonym maps to associate with this field.

SearchField setSynonymMapNames(List<String> synonymMapNames)

Set the synonymMapNames property: A list of the names of synonym maps to associate with this field.

SearchField setVectorEncodingFormat(VectorEncodingFormat vectorEncodingFormat)

Set the vectorEncodingFormat property: The encoding format to interpret the field contents.

SearchField setVectorSearchDimensions(Integer vectorSearchDimensions)

Set the vectorSearchDimensions property: The dimensionality of the vector field.

SearchField setVectorSearchProfileName(String vectorSearchProfileName)

Set the vectorSearchProfileName property: The name of the vector search profile that specifies the algorithm and vectorizer to use when searching the vector field.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from java.lang.Object

Constructor Details

SearchField

public SearchField(String name, SearchFieldDataType type)

Creates an instance of SearchField class.

Parameters:

name - the name value to set.
type - the type value to set.

Method Details

fromJson

public static SearchField fromJson(JsonReader jsonReader)

Reads an instance of SearchField from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of SearchField if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.

Throws:

IOException

- If the deserialized JSON object was missing any required properties.

getAnalyzerName

public LexicalAnalyzerName getAnalyzerName()

Get the analyzerName property: The name of the analyzer to use for the field. This option can be used only with searchable fields and it can't be set together with either searchAnalyzer or indexAnalyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields.

Returns:

the analyzerName value.

getFields

public List getFields()

Get the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType). Must be null or empty for simple fields.

Returns:

the fields value.

getIndexAnalyzerName

public LexicalAnalyzerName getIndexAnalyzerName()

Get the indexAnalyzerName property: The name of the analyzer used at indexing time for the field. This option can be used only with searchable fields. It must be set together with searchAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields.

Returns:

the indexAnalyzerName value.

getName

public String getName()

Get the name property: The name of the field, which must be unique within the fields collection of the index or parent field.

Returns:

the name value.

getSearchAnalyzerName

public LexicalAnalyzerName getSearchAnalyzerName()

Get the searchAnalyzerName property: The name of the analyzer used at search time for the field. This option can be used only with searchable fields. It must be set together with indexAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. This analyzer can be updated on an existing field. Must be null for complex fields.

Returns:

the searchAnalyzerName value.

getSynonymMapNames

public List getSynonymMapNames()

Get the synonymMapNames property: A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields.

Returns:

the synonymMapNames value.

getType

public SearchFieldDataType getType()

Get the type property: The data type of the field.

Returns:

the type value.

getVectorEncodingFormat

public VectorEncodingFormat getVectorEncodingFormat()

Get the vectorEncodingFormat property: The encoding format to interpret the field contents.

Returns:

the vectorEncodingFormat value.

getVectorSearchDimensions

public Integer getVectorSearchDimensions()

Get the vectorSearchDimensions property: The dimensionality of the vector field.

Returns:

the vectorSearchDimensions value.

getVectorSearchProfileName

public String getVectorSearchProfileName()

Get the vectorSearchProfileName property: The name of the vector search profile that specifies the algorithm and vectorizer to use when searching the vector field.

Returns:

the vectorSearchProfileName value.

isFacetable

public Boolean isFacetable()

Get the facetable property: A value indicating whether to enable the field to be referenced in facet queries. Typically used in a presentation of search results that includes hit count by category (for example, search for digital cameras and see hits by brand, by megapixels, by price, and so on). This property must be null for complex fields. Fields of type Edm.GeographyPoint or Collection(Edm.GeographyPoint) cannot be facetable. Default is true for all other simple fields.

Returns:

the facetable value.

isFilterable

public Boolean isFilterable()

Get the filterable property: A value indicating whether to enable the field to be referenced in $filter queries. filterable differs from searchable in how strings are handled. Fields of type Edm.String or Collection(Edm.String) that are filterable do not undergo word-breaking, so comparisons are for exact matches only. For example, if you set such a field f to "sunny day", $filter=f eq 'sunny' will find no matches, but $filter=f eq 'sunny day' will. This property must be null for complex fields. Default is true for simple fields and null for complex fields.

Returns:

the filterable value.

isHidden

public Boolean isHidden()

Get the hidden property: A value indicating whether the field will be returned in a search result. This property must be false for key fields, and must be null for complex fields. You can hide a field from search results if you want to use it only as a filter, for sorting, or for scoring. This property can also be changed on existing fields and enabling it does not cause an increase in index storage requirements.

Returns:

the hidden value.

isKey

public Boolean isKey()

Get the key property: A value indicating whether the field uniquely identifies documents in the index. Exactly one top-level field in each index must be chosen as the key field and it must be of type Edm.String. Key fields can be used to look up documents directly and update or delete specific documents. Default is false for simple fields and null for complex fields.

Returns:

the key value.

isSearchable

public Boolean isSearchable()

Get the searchable property: A value indicating whether the field is full-text searchable. This means it will undergo analysis such as word-breaking during indexing. If you set a searchable field to a value like "sunny day", internally it will be split into the individual tokens "sunny" and "day". This enables full-text searches for these terms. Fields of type Edm.String or Collection(Edm.String) are searchable by default. This property must be false for simple fields of other non-string data types, and it must be null for complex fields. Note: searchable fields consume extra space in your index to accommodate additional tokenized versions of the field value for full-text searches. If you want to save space in your index and you don't need a field to be included in searches, set searchable to false.

Returns:

the searchable value.

isSortable

public Boolean isSortable()

Get the sortable property: A value indicating whether to enable the field to be referenced in $orderby expressions. By default, the search engine sorts results by score, but in many experiences users will want to sort by fields in the documents. A simple field can be sortable only if it is single-valued (it has a single value in the scope of the parent document). Simple collection fields cannot be sortable, since they are multi-valued. Simple sub-fields of complex collections are also multi-valued, and therefore cannot be sortable. This is true whether it's an immediate parent field, or an ancestor field, that's the complex collection. Complex fields cannot be sortable and the sortable property must be null for such fields. The default for sortable is true for single-valued simple fields, false for multi-valued simple fields, and null for complex fields.

Returns:

the sortable value.

isStored

public Boolean isStored()

Get the stored property: An immutable value indicating whether the field will be persisted separately on disk to be returned in a search result. You can disable this option if you don't plan to return the field contents in a search response to save on storage overhead. This can only be set during index creation and only for vector fields. This property cannot be changed for existing fields or set as false for new fields. If this property is set as false, the property 'retrievable' must also be set to false. This property must be true or unset for key fields, for new fields, and for non-vector fields, and it must be null for complex fields. Disabling this property will reduce index storage requirements. The default is true for vector fields.

Returns:

the stored value.

setAnalyzerName

public SearchField setAnalyzerName(LexicalAnalyzerName analyzerName)

Set the analyzerName property: The name of the analyzer to use for the field. This option can be used only with searchable fields and it can't be set together with either searchAnalyzer or indexAnalyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields.

Parameters:

analyzerName - the analyzerName value to set.

Returns:

the SearchField object itself.

setFacetable

public SearchField setFacetable(Boolean facetable)

Set the facetable property: A value indicating whether to enable the field to be referenced in facet queries. Typically used in a presentation of search results that includes hit count by category (for example, search for digital cameras and see hits by brand, by megapixels, by price, and so on). This property must be null for complex fields. Fields of type Edm.GeographyPoint or Collection(Edm.GeographyPoint) cannot be facetable. Default is true for all other simple fields.

Parameters:

facetable - the facetable value to set.

Returns:

the SearchField object itself.

setFields

public SearchField setFields(SearchField[] fields)

Set the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType). Must be null or empty for simple fields.

Parameters:

fields - the fields value to set.

Returns:

the SearchField object itself.

setFields

public SearchField setFields(List fields)

Set the fields property: A list of sub-fields if this is a field of type Edm.ComplexType or Collection(Edm.ComplexType). Must be null or empty for simple fields.

Parameters:

fields - the fields value to set.

Returns:

the SearchField object itself.

setFilterable

public SearchField setFilterable(Boolean filterable)

Set the filterable property: A value indicating whether to enable the field to be referenced in $filter queries. filterable differs from searchable in how strings are handled. Fields of type Edm.String or Collection(Edm.String) that are filterable do not undergo word-breaking, so comparisons are for exact matches only. For example, if you set such a field f to "sunny day", $filter=f eq 'sunny' will find no matches, but $filter=f eq 'sunny day' will. This property must be null for complex fields. Default is true for simple fields and null for complex fields.

Parameters:

filterable - the filterable value to set.

Returns:

the SearchField object itself.

setHidden

public SearchField setHidden(Boolean hidden)

Set the hidden property: A value indicating whether the field will be returned in a search result. This property must be false for key fields, and must be null for complex fields. You can hide a field from search results if you want to use it only as a filter, for sorting, or for scoring. This property can also be changed on existing fields and enabling it does not cause an increase in index storage requirements.

Parameters:

hidden - the hidden value to set.

Returns:

the SearchField object itself.

setIndexAnalyzerName

public SearchField setIndexAnalyzerName(LexicalAnalyzerName indexAnalyzerName)

Set the indexAnalyzerName property: The name of the analyzer used at indexing time for the field. This option can be used only with searchable fields. It must be set together with searchAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. Once the analyzer is chosen, it cannot be changed for the field. Must be null for complex fields.

Parameters:

indexAnalyzerName - the indexAnalyzerName value to set.

Returns:

the SearchField object itself.

setKey

public SearchField setKey(Boolean key)

Set the key property: A value indicating whether the field uniquely identifies documents in the index. Exactly one top-level field in each index must be chosen as the key field and it must be of type Edm.String. Key fields can be used to look up documents directly and update or delete specific documents. Default is false for simple fields and null for complex fields.

Parameters:

key - the key value to set.

Returns:

the SearchField object itself.

setSearchAnalyzerName

public SearchField setSearchAnalyzerName(LexicalAnalyzerName searchAnalyzerName)

Set the searchAnalyzerName property: The name of the analyzer used at search time for the field. This option can be used only with searchable fields. It must be set together with indexAnalyzer and it cannot be set together with the analyzer option. This property cannot be set to the name of a language analyzer; use the analyzer property instead if you need a language analyzer. This analyzer can be updated on an existing field. Must be null for complex fields.

Parameters:

searchAnalyzerName - the searchAnalyzerName value to set.

Returns:

the SearchField object itself.

setSearchable

public SearchField setSearchable(Boolean searchable)

Set the searchable property: A value indicating whether the field is full-text searchable. This means it will undergo analysis such as word-breaking during indexing. If you set a searchable field to a value like "sunny day", internally it will be split into the individual tokens "sunny" and "day". This enables full-text searches for these terms. Fields of type Edm.String or Collection(Edm.String) are searchable by default. This property must be false for simple fields of other non-string data types, and it must be null for complex fields. Note: searchable fields consume extra space in your index to accommodate additional tokenized versions of the field value for full-text searches. If you want to save space in your index and you don't need a field to be included in searches, set searchable to false.

Parameters:

searchable - the searchable value to set.

Returns:

the SearchField object itself.

setSortable

public SearchField setSortable(Boolean sortable)

Set the sortable property: A value indicating whether to enable the field to be referenced in $orderby expressions. By default, the search engine sorts results by score, but in many experiences users will want to sort by fields in the documents. A simple field can be sortable only if it is single-valued (it has a single value in the scope of the parent document). Simple collection fields cannot be sortable, since they are multi-valued. Simple sub-fields of complex collections are also multi-valued, and therefore cannot be sortable. This is true whether it's an immediate parent field, or an ancestor field, that's the complex collection. Complex fields cannot be sortable and the sortable property must be null for such fields. The default for sortable is true for single-valued simple fields, false for multi-valued simple fields, and null for complex fields.

Parameters:

sortable - the sortable value to set.

Returns:

the SearchField object itself.

setStored

public SearchField setStored(Boolean stored)

Set the stored property: An immutable value indicating whether the field will be persisted separately on disk to be returned in a search result. You can disable this option if you don't plan to return the field contents in a search response to save on storage overhead. This can only be set during index creation and only for vector fields. This property cannot be changed for existing fields or set as false for new fields. If this property is set as false, the property 'retrievable' must also be set to false. This property must be true or unset for key fields, for new fields, and for non-vector fields, and it must be null for complex fields. Disabling this property will reduce index storage requirements. The default is true for vector fields.

Parameters:

stored - the stored value to set.

Returns:

the SearchField object itself.

setSynonymMapNames

public SearchField setSynonymMapNames(String[] synonymMapNames)

Set the synonymMapNames property: A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields.

Parameters:

synonymMapNames - the synonymMapNames value to set.

Returns:

the SearchField object itself.

setSynonymMapNames

public SearchField setSynonymMapNames(List synonymMapNames)

Set the synonymMapNames property: A list of the names of synonym maps to associate with this field. This option can be used only with searchable fields. Currently only one synonym map per field is supported. Assigning a synonym map to a field ensures that query terms targeting that field are expanded at query-time using the rules in the synonym map. This attribute can be changed on existing fields. Must be null or an empty collection for complex fields.

Parameters:

synonymMapNames - the synonymMapNames value to set.

Returns:

the SearchField object itself.

setVectorEncodingFormat

public SearchField setVectorEncodingFormat(VectorEncodingFormat vectorEncodingFormat)

Set the vectorEncodingFormat property: The encoding format to interpret the field contents.

Parameters:

vectorEncodingFormat - the vectorEncodingFormat value to set.

Returns:

the SearchField object itself.

setVectorSearchDimensions

public SearchField setVectorSearchDimensions(Integer vectorSearchDimensions)

Set the vectorSearchDimensions property: The dimensionality of the vector field.

Parameters:

vectorSearchDimensions - the vectorSearchDimensions value to set.

Returns:

the SearchField object itself.

setVectorSearchProfileName

public SearchField setVectorSearchProfileName(String vectorSearchProfileName)

Set the vectorSearchProfileName property: The name of the vector search profile that specifies the algorithm and vectorizer to use when searching the vector field.

Parameters:

vectorSearchProfileName - the vectorSearchProfileName value to set.

Returns:

the SearchField object itself.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to