diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AnalyzeRequestConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AnalyzeRequestConverter.java index 8827b9207541..5dcc1e5e3e1e 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AnalyzeRequestConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/AnalyzeRequestConverter.java @@ -35,16 +35,16 @@ public static AnalyzeTextOptions map(com.azure.search.documents.indexes.implemen } if (obj.getCharFilters() != null) { - List charFilters = - obj.getCharFilters().stream().map(CharFilterNameConverter::map).collect(Collectors.toList()); - analyzeTextOptions.setCharFilters(charFilters); + analyzeTextOptions.setCharFilters(obj.getCharFilters().stream() + .map(CharFilterNameConverter::map) + .toArray(CharFilterName[]::new)); } if (obj.getTokenFilters() != null) { - List tokenFilters = - obj.getTokenFilters().stream().map(TokenFilterNameConverter::map).collect(Collectors.toList()); - analyzeTextOptions.setTokenFilters(tokenFilters); + analyzeTextOptions.setTokenFilters(obj.getTokenFilters().stream() + .map(TokenFilterNameConverter::map) + .toArray(TokenFilterName[]::new)); } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/CjkBigramTokenFilterConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/CjkBigramTokenFilterConverter.java index 3f36516036f6..ca45d321dc27 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/CjkBigramTokenFilterConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/CjkBigramTokenFilterConverter.java @@ -4,7 +4,6 @@ package com.azure.search.documents.implementation.converters; import com.azure.search.documents.indexes.models.CjkBigramTokenFilter; -import com.azure.search.documents.indexes.models.CjkBigramTokenFilterScripts; import java.util.List; import java.util.stream.Collectors; @@ -28,9 +27,9 @@ public static CjkBigramTokenFilter map(com.azure.search.documents.indexes.implem cjkBigramTokenFilter.setOutputUnigrams(outputUnigrams); if (obj.getIgnoreScripts() != null) { - List ignoreScripts = - obj.getIgnoreScripts().stream().map(CjkBigramTokenFilterScriptsConverter::map).collect(Collectors.toList()); - cjkBigramTokenFilter.setIgnoreScripts(ignoreScripts); + cjkBigramTokenFilter.setIgnoreScripts(obj.getIgnoreScripts().stream() + .map(CjkBigramTokenFilterScriptsConverter::map) + .collect(Collectors.toList())); } return cjkBigramTokenFilter; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EdgeNGramTokenizerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EdgeNGramTokenizerConverter.java index 9237bb4bff09..2629716afe66 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EdgeNGramTokenizerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EdgeNGramTokenizerConverter.java @@ -4,7 +4,6 @@ package com.azure.search.documents.implementation.converters; import com.azure.search.documents.indexes.models.EdgeNGramTokenizer; -import com.azure.search.documents.indexes.models.TokenCharacterKind; import java.util.List; import java.util.stream.Collectors; @@ -28,9 +27,9 @@ public static EdgeNGramTokenizer map(com.azure.search.documents.indexes.implemen edgeNGramTokenizer.setMaxGram(maxGram); if (obj.getTokenChars() != null) { - List tokenChars = - obj.getTokenChars().stream().map(TokenCharacterKindConverter::map).collect(Collectors.toList()); - edgeNGramTokenizer.setTokenChars(tokenChars); + edgeNGramTokenizer.setTokenChars(obj.getTokenChars().stream() + .map(TokenCharacterKindConverter::map) + .collect(Collectors.toList())); } Integer minGram = obj.getMinGram(); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ElisionTokenFilterConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ElisionTokenFilterConverter.java index fd274a727534..5b04318783c5 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ElisionTokenFilterConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ElisionTokenFilterConverter.java @@ -24,8 +24,7 @@ public static ElisionTokenFilter map(com.azure.search.documents.indexes.implemen ElisionTokenFilter elisionTokenFilter = new ElisionTokenFilter(obj.getName()); if (obj.getArticles() != null) { - List articles = new ArrayList<>(obj.getArticles()); - elisionTokenFilter.setArticles(articles); + elisionTokenFilter.setArticles(obj.getArticles()); } return elisionTokenFilter; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EntityRecognitionSkillConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EntityRecognitionSkillConverter.java index 17c91d75a62d..42e15524b92d 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EntityRecognitionSkillConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/EntityRecognitionSkillConverter.java @@ -3,7 +3,6 @@ package com.azure.search.documents.implementation.converters; -import com.azure.search.documents.indexes.models.EntityCategory; import com.azure.search.documents.indexes.models.EntityRecognitionSkill; import com.azure.search.documents.indexes.models.EntityRecognitionSkillLanguage; import com.azure.search.documents.indexes.models.InputFieldMappingEntry; @@ -52,9 +51,9 @@ public static EntityRecognitionSkill map(com.azure.search.documents.indexes.impl } if (obj.getCategories() != null) { - List categories = - obj.getCategories().stream().map(EntityCategoryConverter::map).collect(Collectors.toList()); - entityRecognitionSkill.setCategories(categories); + entityRecognitionSkill.setCategories(obj.getCategories().stream() + .map(EntityCategoryConverter::map) + .collect(Collectors.toList())); } Double minimumPrecision = obj.getMinimumPrecision(); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ImageAnalysisSkillConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ImageAnalysisSkillConverter.java index ddb96e58578d..76eabdc29d13 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ImageAnalysisSkillConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ImageAnalysisSkillConverter.java @@ -5,10 +5,8 @@ import com.azure.search.documents.indexes.models.ImageAnalysisSkill; import com.azure.search.documents.indexes.models.ImageAnalysisSkillLanguage; -import com.azure.search.documents.indexes.models.ImageDetail; import com.azure.search.documents.indexes.models.InputFieldMappingEntry; import com.azure.search.documents.indexes.models.OutputFieldMappingEntry; -import com.azure.search.documents.indexes.models.VisualFeature; import java.util.List; import java.util.stream.Collectors; @@ -44,9 +42,9 @@ public static ImageAnalysisSkill map(com.azure.search.documents.indexes.implemen imageAnalysisSkill.setDescription(description); if (obj.getVisualFeatures() != null) { - List visualFeatures = - obj.getVisualFeatures().stream().map(VisualFeatureConverter::map).collect(Collectors.toList()); - imageAnalysisSkill.setVisualFeatures(visualFeatures); + imageAnalysisSkill.setVisualFeatures(obj.getVisualFeatures().stream() + .map(VisualFeatureConverter::map) + .collect(Collectors.toList())); } if (obj.getDefaultLanguageCode() != null) { @@ -56,9 +54,9 @@ public static ImageAnalysisSkill map(com.azure.search.documents.indexes.implemen } if (obj.getDetails() != null) { - List details = - obj.getDetails().stream().map(ImageDetailConverter::map).collect(Collectors.toList()); - imageAnalysisSkill.setDetails(details); + imageAnalysisSkill.setDetails(obj.getDetails().stream() + .map(ImageDetailConverter::map) + .collect(Collectors.toList())); } return imageAnalysisSkill; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/LuceneStandardAnalyzerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/LuceneStandardAnalyzerConverter.java index 3a3eb17a747d..3e092e9c830d 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/LuceneStandardAnalyzerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/LuceneStandardAnalyzerConverter.java @@ -27,8 +27,7 @@ public static LuceneStandardAnalyzer map(com.azure.search.documents.indexes.impl luceneStandardAnalyzer.setMaxTokenLength(maxTokenLength); if (obj.getStopwords() != null) { - List stopwords = new ArrayList<>(obj.getStopwords()); - luceneStandardAnalyzer.setStopwords(stopwords); + luceneStandardAnalyzer.setStopwords(obj.getStopwords()); } return luceneStandardAnalyzer; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/NGramTokenizerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/NGramTokenizerConverter.java index 11d9135727dd..7c551de884b6 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/NGramTokenizerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/NGramTokenizerConverter.java @@ -4,7 +4,6 @@ package com.azure.search.documents.implementation.converters; import com.azure.search.documents.indexes.models.NGramTokenizer; -import com.azure.search.documents.indexes.models.TokenCharacterKind; import java.util.List; import java.util.stream.Collectors; @@ -27,9 +26,9 @@ public static NGramTokenizer map(com.azure.search.documents.indexes.implementati nGramTokenizer.setMaxGram(maxGram); if (obj.getTokenChars() != null) { - List tokenChars = - obj.getTokenChars().stream().map(TokenCharacterKindConverter::map).collect(Collectors.toList()); - nGramTokenizer.setTokenChars(tokenChars); + nGramTokenizer.setTokenChars(obj.getTokenChars().stream() + .map(TokenCharacterKindConverter::map) + .collect(Collectors.toList())); } Integer minGram = obj.getMinGram(); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternAnalyzerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternAnalyzerConverter.java index 3c629c15b7b5..591825343514 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternAnalyzerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternAnalyzerConverter.java @@ -32,14 +32,13 @@ public static PatternAnalyzer map(com.azure.search.documents.indexes.implementat patternAnalyzer.setPattern(pattern); if (obj.getFlags() != null) { - List regexFlags = - Arrays.stream(obj.getFlags().toString().split("\\|")).map(RegexFlags::fromString).collect(Collectors.toList()); - patternAnalyzer.setFlags(regexFlags); + patternAnalyzer.setFlags(Arrays.stream(obj.getFlags().toString().split("\\|")) + .map(RegexFlags::fromString) + .collect(Collectors.toList())); } if (obj.getStopwords() != null) { - List stopwords = new ArrayList<>(obj.getStopwords()); - patternAnalyzer.setStopwords(stopwords); + patternAnalyzer.setStopwords(obj.getStopwords()); } return patternAnalyzer; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternTokenizerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternTokenizerConverter.java index 89cf03629166..5f0aeb5a9104 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternTokenizerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/PatternTokenizerConverter.java @@ -7,7 +7,6 @@ import com.azure.search.documents.indexes.models.RegexFlags; import java.util.Arrays; -import java.util.List; import java.util.stream.Collectors; /** @@ -28,9 +27,9 @@ public static PatternTokenizer map(com.azure.search.documents.indexes.implementa patternTokenizer.setPattern(pattern); if (obj.getFlags() != null) { - List regexFlags = - Arrays.stream(obj.getFlags().toString().split("\\|")).map(RegexFlags::fromString).collect(Collectors.toList()); - patternTokenizer.setFlags(regexFlags); + patternTokenizer.setFlags(Arrays.stream(obj.getFlags().toString().split("\\|")) + .map(RegexFlags::fromString) + .collect(Collectors.toList())); } Integer group = obj.getGroup(); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ScoringProfileConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ScoringProfileConverter.java index 78fc6dd367ac..610eb69f6b8c 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ScoringProfileConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/ScoringProfileConverter.java @@ -3,7 +3,6 @@ package com.azure.search.documents.implementation.converters; -import com.azure.search.documents.indexes.models.ScoringFunction; import com.azure.search.documents.indexes.models.ScoringFunctionAggregation; import com.azure.search.documents.indexes.models.ScoringProfile; import com.azure.search.documents.indexes.models.TextWeights; @@ -26,9 +25,9 @@ public static ScoringProfile map(com.azure.search.documents.indexes.implementati ScoringProfile scoringProfile = new ScoringProfile(obj.getName()); if (obj.getFunctions() != null) { - List functions = - obj.getFunctions().stream().map(ScoringFunctionConverter::map).collect(Collectors.toList()); - scoringProfile.setFunctions(functions); + scoringProfile.setFunctions(obj.getFunctions().stream() + .map(ScoringFunctionConverter::map) + .collect(Collectors.toList())); } if (obj.getTextWeights() != null) { diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/StopAnalyzerConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/StopAnalyzerConverter.java index 2b8f8495b1d5..e59cab202029 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/StopAnalyzerConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/StopAnalyzerConverter.java @@ -22,8 +22,7 @@ public static StopAnalyzer map(com.azure.search.documents.indexes.implementation StopAnalyzer stopAnalyzer = new StopAnalyzer(obj.getName()); if (obj.getStopwords() != null) { - List stopwords = new ArrayList<>(obj.getStopwords()); - stopAnalyzer.setStopwords(stopwords); + stopAnalyzer.setStopwords(obj.getStopwords()); } return stopAnalyzer; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/WordDelimiterTokenFilterConverter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/WordDelimiterTokenFilterConverter.java index 988967cd2d35..a8f0aff32e22 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/WordDelimiterTokenFilterConverter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/implementation/converters/WordDelimiterTokenFilterConverter.java @@ -27,8 +27,7 @@ public static WordDelimiterTokenFilter map(com.azure.search.documents.indexes.im wordDelimiterTokenFilter.setNumbersCatenated(catenateNumbers); if (obj.getProtectedWords() != null) { - List protectedWords = new ArrayList<>(obj.getProtectedWords()); - wordDelimiterTokenFilter.setProtectedWords(protectedWords); + wordDelimiterTokenFilter.setProtectedWords(obj.getProtectedWords()); } Boolean generateNumberParts = obj.isGenerateNumberParts(); diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AnalyzeTextOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AnalyzeTextOptions.java index 4039507f1429..a7255502772b 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AnalyzeTextOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/AnalyzeTextOptions.java @@ -5,6 +5,8 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Arrays; import java.util.List; /** @@ -201,8 +203,8 @@ public List getTokenFilters() { * @param tokenFilters the tokenFilters value to set. * @return the AnalyzeRequest object itself. */ - public AnalyzeTextOptions setTokenFilters(List tokenFilters) { - this.tokenFilters = tokenFilters; + public AnalyzeTextOptions setTokenFilters(TokenFilterName... tokenFilters) { + this.tokenFilters = (tokenFilters == null) ? null : Arrays.asList(tokenFilters); return this; } @@ -225,8 +227,8 @@ public List getCharFilters() { * @param charFilters the charFilters value to set. * @return the AnalyzeRequest object itself. */ - public AnalyzeTextOptions setCharFilters(List charFilters) { - this.charFilters = charFilters; + public AnalyzeTextOptions setCharFilters(CharFilterName... charFilters) { + this.charFilters = (charFilters == null) ? null : Arrays.asList(charFilters); return this; } } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CjkBigramTokenFilter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CjkBigramTokenFilter.java index 65d3b31763e9..9df7360dac2f 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CjkBigramTokenFilter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CjkBigramTokenFilter.java @@ -6,8 +6,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -58,6 +61,18 @@ public List getIgnoreScripts() { * @param ignoreScripts the ignoreScripts value to set. * @return the CjkBigramTokenFilter object itself. */ + public CjkBigramTokenFilter setIgnoreScripts(CjkBigramTokenFilterScripts... ignoreScripts) { + this.ignoreScripts = (ignoreScripts == null) ? null : Arrays.asList(ignoreScripts); + return this; + } + + /** + * Set the ignoreScripts property: The scripts to ignore. + * + * @param ignoreScripts the ignoreScripts value to set. + * @return the CjkBigramTokenFilter object itself. + */ + @JsonSetter public CjkBigramTokenFilter setIgnoreScripts(List ignoreScripts) { this.ignoreScripts = ignoreScripts; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CustomAnalyzer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CustomAnalyzer.java index e6bab959e9fd..a5295162b851 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CustomAnalyzer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/CustomAnalyzer.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -102,6 +105,21 @@ public List getTokenFilters() { * @param tokenFilters the tokenFilters value to set. * @return the CustomAnalyzer object itself. */ + public CustomAnalyzer setTokenFilters(TokenFilterName... tokenFilters) { + this.tokenFilters = (tokenFilters == null) ? null : Arrays.asList(tokenFilters); + return this; + } + + /** + * Set the tokenFilters property: A list of token filters used to filter + * out or modify the tokens generated by a tokenizer. For example, you can + * specify a lowercase filter that converts all characters to lowercase. + * The filters are run in the order in which they are listed. + * + * @param tokenFilters the tokenFilters value to set. + * @return the CustomAnalyzer object itself. + */ + @JsonSetter public CustomAnalyzer setTokenFilters(List tokenFilters) { this.tokenFilters = tokenFilters; return this; @@ -128,6 +146,21 @@ public List getCharFilters() { * @param charFilters the charFilters value to set. * @return the CustomAnalyzer object itself. */ + public CustomAnalyzer setCharFilters(CharFilterName... charFilters) { + this.charFilters = (charFilters == null) ? null : Arrays.asList(charFilters); + return this; + } + + /** + * Set the charFilters property: A list of character filters used to + * prepare input text before it is processed by the tokenizer. For + * instance, they can replace certain characters or symbols. The filters + * are run in the order in which they are listed. + * + * @param charFilters the charFilters value to set. + * @return the CustomAnalyzer object itself. + */ + @JsonSetter public CustomAnalyzer setCharFilters(List charFilters) { this.charFilters = charFilters; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EdgeNGramTokenizer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EdgeNGramTokenizer.java index 67fed3cf4f00..25ff7da87421 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EdgeNGramTokenizer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EdgeNGramTokenizer.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -106,6 +109,18 @@ public List getTokenChars() { * @param tokenChars the tokenChars value to set. * @return the EdgeNGramTokenizer object itself. */ + public EdgeNGramTokenizer setTokenChars(TokenCharacterKind... tokenChars) { + this.tokenChars = (tokenChars == null) ? null : Arrays.asList(tokenChars); + return this; + } + + /** + * Set the tokenChars property: Character classes to keep in the tokens. + * + * @param tokenChars the tokenChars value to set. + * @return the EdgeNGramTokenizer object itself. + */ + @JsonSetter public EdgeNGramTokenizer setTokenChars(List tokenChars) { this.tokenChars = tokenChars; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ElisionTokenFilter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ElisionTokenFilter.java index 98dcbaa63db1..738470979066 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ElisionTokenFilter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ElisionTokenFilter.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -49,6 +52,18 @@ public List getArticles() { * @param articles the articles value to set. * @return the ElisionTokenFilter object itself. */ + public ElisionTokenFilter setArticles(String... articles) { + this.articles = (articles == null) ? null : Arrays.asList(articles); + return this; + } + + /** + * Set the articles property: The set of articles to remove. + * + * @param articles the articles value to set. + * @return the ElisionTokenFilter object itself. + */ + @JsonSetter public ElisionTokenFilter setArticles(List articles) { this.articles = articles; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkill.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkill.java index d7cc6773e864..5e572dad917e 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkill.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/EntityRecognitionSkill.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -76,6 +79,19 @@ public List getCategories() { * @param categories the categories value to set. * @return the EntityRecognitionSkill object itself. */ + public EntityRecognitionSkill setCategories(EntityCategory... categories) { + this.categories = (categories == null) ? null : Arrays.asList(categories); + return this; + } + + /** + * Set the categories property: A list of entity categories that should be + * extracted. + * + * @param categories the categories value to set. + * @return the EntityRecognitionSkill object itself. + */ + @JsonSetter public EntityRecognitionSkill setCategories(List categories) { this.categories = categories; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ImageAnalysisSkill.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ImageAnalysisSkill.java index 45eea7cd1fe2..e86bd6c40f5a 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ImageAnalysisSkill.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ImageAnalysisSkill.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -87,6 +90,18 @@ public List getVisualFeatures() { * @param visualFeatures the visualFeatures value to set. * @return the ImageAnalysisSkill object itself. */ + public ImageAnalysisSkill setVisualFeatures(VisualFeature... visualFeatures) { + this.visualFeatures = (visualFeatures == null) ? null : Arrays.asList(visualFeatures); + return this; + } + + /** + * Set the visualFeatures property: A list of visual features. + * + * @param visualFeatures the visualFeatures value to set. + * @return the ImageAnalysisSkill object itself. + */ + @JsonSetter public ImageAnalysisSkill setVisualFeatures(List visualFeatures) { this.visualFeatures = visualFeatures; return this; @@ -109,6 +124,19 @@ public List getDetails() { * @param details the details value to set. * @return the ImageAnalysisSkill object itself. */ + public ImageAnalysisSkill setDetails(ImageDetail... details) { + this.details = (details == null) ? null : Arrays.asList(details); + return this; + } + + /** + * Set the details property: A string indicating which domain-specific + * details to return. + * + * @param details the details value to set. + * @return the ImageAnalysisSkill object itself. + */ + @JsonSetter public ImageAnalysisSkill setDetails(List details) { this.details = details; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/InputFieldMappingEntry.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/InputFieldMappingEntry.java index 27cf9378ef8c..6d3b3d1786db 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/InputFieldMappingEntry.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/InputFieldMappingEntry.java @@ -6,6 +6,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -115,6 +118,19 @@ public List getInputs() { * @param inputs the inputs value to set. * @return the InputFieldMappingEntry object itself. */ + public InputFieldMappingEntry setInputs(InputFieldMappingEntry... inputs) { + this.inputs = (inputs == null) ? null : Arrays.asList(inputs); + return this; + } + + /** + * Set the inputs property: The recursive inputs used when creating a + * complex type. + * + * @param inputs the inputs value to set. + * @return the InputFieldMappingEntry object itself. + */ + @JsonSetter public InputFieldMappingEntry setInputs(List inputs) { this.inputs = inputs; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/LuceneStandardAnalyzer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/LuceneStandardAnalyzer.java index da9e445230dc..e1bc743ff11d 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/LuceneStandardAnalyzer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/LuceneStandardAnalyzer.java @@ -6,8 +6,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -83,6 +86,18 @@ public List getStopwords() { * @param stopwords the stopwords value to set. * @return the LuceneStandardAnalyzer object itself. */ + public LuceneStandardAnalyzer setStopwords(String... stopwords) { + this.stopwords = (stopwords == null) ? null : Arrays.asList(stopwords); + return this; + } + + /** + * Set the stopwords property: A list of stopwords. + * + * @param stopwords the stopwords value to set. + * @return the LuceneStandardAnalyzer object itself. + */ + @JsonSetter public LuceneStandardAnalyzer setStopwords(List stopwords) { this.stopwords = stopwords; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/NGramTokenizer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/NGramTokenizer.java index fb2bcf1519f6..218e63130f08 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/NGramTokenizer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/NGramTokenizer.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -106,6 +109,18 @@ public List getTokenChars() { * @param tokenChars the tokenChars value to set. * @return the NGramTokenizer object itself. */ + public NGramTokenizer setTokenChars(TokenCharacterKind... tokenChars) { + this.tokenChars = (tokenChars == null) ? null : Arrays.asList(tokenChars); + return this; + } + + /** + * Set the tokenChars property: Character classes to keep in the tokens. + * + * @param tokenChars the tokenChars value to set. + * @return the NGramTokenizer object itself. + */ + @JsonSetter public NGramTokenizer setTokenChars(List tokenChars) { this.tokenChars = tokenChars; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternAnalyzer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternAnalyzer.java index 7e76909eb019..be1ac6348ec3 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternAnalyzer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternAnalyzer.java @@ -5,9 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.Arrays; import java.util.List; /** @@ -115,6 +117,18 @@ public List getFlags() { * @param flags the flags value to set. * @return the PatternAnalyzer object itself. */ + public PatternAnalyzer setFlags(RegexFlags... flags) { + this.flags = (flags == null) ? null : Arrays.asList(flags); + return this; + } + + /** + * Set the flags property: Regular expression flags. + * + * @param flags the flags value to set. + * @return the PatternAnalyzer object itself. + */ + @JsonSetter public PatternAnalyzer setFlags(List flags) { this.flags = flags; return this; @@ -135,6 +149,18 @@ public List getStopwords() { * @param stopwords the stopwords value to set. * @return the PatternAnalyzer object itself. */ + public PatternAnalyzer setStopwords(String... stopwords) { + this.stopwords = (stopwords == null) ? null : Arrays.asList(stopwords); + return this; + } + + /** + * Set the stopwords property: A list of stopwords. + * + * @param stopwords the stopwords value to set. + * @return the PatternAnalyzer object itself. + */ + @JsonSetter public PatternAnalyzer setStopwords(List stopwords) { this.stopwords = stopwords; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternTokenizer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternTokenizer.java index 3b685f78a23f..03f3842f9a37 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternTokenizer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/PatternTokenizer.java @@ -5,9 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.Arrays; import java.util.List; /** @@ -90,6 +92,18 @@ public List getFlags() { * @param flags the flags value to set. * @return the PatternTokenizer object itself. */ + public PatternTokenizer setFlags(RegexFlags... flags) { + this.flags = (flags == null) ? null : Arrays.asList(flags); + return this; + } + + /** + * Set the flags property: Regular expression flags. + * + * @param flags the flags value to set. + * @return the PatternTokenizer object itself. + */ + @JsonSetter public PatternTokenizer setFlags(List flags) { this.flags = flags; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ScoringProfile.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ScoringProfile.java index 750a97cfcb90..c07e1aee0718 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ScoringProfile.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/ScoringProfile.java @@ -6,6 +6,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -100,6 +103,19 @@ public List getFunctions() { * @param functions the functions value to set. * @return the ScoringProfile object itself. */ + public ScoringProfile setFunctions(ScoringFunction... functions) { + this.functions = (functions == null) ? null : Arrays.asList(functions); + return this; + } + + /** + * Set the functions property: The collection of functions that influence + * the scoring of documents. + * + * @param functions the functions value to set. + * @return the ScoringProfile object itself. + */ + @JsonSetter public ScoringProfile setFunctions(List functions) { this.functions = functions; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java index 130aaef4938b..64b5d61ce0e0 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchField.java @@ -7,6 +7,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -683,6 +686,24 @@ public List getSynonymMapNames() { * @param synonymMapNames the synonymMap names to set. * @return the SearchField object itself. */ + public SearchField setSynonymMapNames(String... synonymMapNames) { + this.synonymMapNames = (synonymMapNames == null) ? null : Arrays.asList(synonymMapNames); + return this; + } + + /** + * Set the synonymMaps 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. + * + * @param synonymMapNames the synonymMap names to set. + * @return the SearchField object itself. + */ + @JsonSetter public SearchField setSynonymMapNames(List synonymMapNames) { this.synonymMapNames = synonymMapNames; return this; @@ -707,6 +728,20 @@ public List getFields() { * @param fields the fields value to set. * @return the SearchField object itself. */ + public SearchField setFields(SearchField... fields) { + this.fields = (fields == null) ? null : Arrays.asList(fields); + return this; + } + + /** + * 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. + * + * @param fields the fields value to set. + * @return the SearchField object itself. + */ + @JsonSetter public SearchField setFields(List fields) { this.fields = fields; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndex.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndex.java index 769a2d677412..6d20056eb043 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndex.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndex.java @@ -6,6 +6,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -152,6 +155,18 @@ public List getFields() { * @param fields the fields value to set. * @return the SearchIndex object itself. */ + public SearchIndex setFields(SearchField... fields) { + this.fields = (fields == null) ? null : Arrays.asList(fields); + return this; + } + + /** + * Set the fields property: The fields of the index. + * + * @param fields the fields value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setFields(List fields) { this.fields = fields; return this; @@ -172,6 +187,18 @@ public List getScoringProfiles() { * @param scoringProfiles the scoringProfiles value to set. * @return the SearchIndex object itself. */ + public SearchIndex setScoringProfiles(ScoringProfile... scoringProfiles) { + this.scoringProfiles = (scoringProfiles == null) ? null : Arrays.asList(scoringProfiles); + return this; + } + + /** + * Set the scoringProfiles property: The scoring profiles for the index. + * + * @param scoringProfiles the scoringProfiles value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setScoringProfiles(List scoringProfiles) { this.scoringProfiles = scoringProfiles; return this; @@ -240,6 +267,18 @@ public List getSuggesters() { * @param suggesters the suggesters value to set. * @return the SearchIndex object itself. */ + public SearchIndex setSuggesters(SearchSuggester... suggesters) { + this.suggesters = (suggesters == null) ? null : Arrays.asList(suggesters); + return this; + } + + /** + * Set the suggesters property: The suggesters for the index. + * + * @param suggesters the suggesters value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setSuggesters(List suggesters) { this.suggesters = suggesters; return this; @@ -260,6 +299,18 @@ public List getAnalyzers() { * @param analyzers the analyzers value to set. * @return the SearchIndex object itself. */ + public SearchIndex setAnalyzers(LexicalAnalyzer... analyzers) { + this.analyzers = (analyzers == null) ? null : Arrays.asList(analyzers); + return this; + } + + /** + * Set the analyzers property: The analyzers for the index. + * + * @param analyzers the analyzers value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setAnalyzers(List analyzers) { this.analyzers = analyzers; return this; @@ -280,6 +331,18 @@ public List getTokenizers() { * @param tokenizers the tokenizers value to set. * @return the SearchIndex object itself. */ + public SearchIndex setTokenizers(LexicalTokenizer... tokenizers) { + this.tokenizers = (tokenizers == null) ? null : Arrays.asList(tokenizers); + return this; + } + + /** + * Set the tokenizers property: The tokenizers for the index. + * + * @param tokenizers the tokenizers value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setTokenizers(List tokenizers) { this.tokenizers = tokenizers; return this; @@ -300,6 +363,18 @@ public List getTokenFilters() { * @param tokenFilters the tokenFilters value to set. * @return the SearchIndex object itself. */ + public SearchIndex setTokenFilters(TokenFilter... tokenFilters) { + this.tokenFilters = (tokenFilters == null) ? null : Arrays.asList(tokenFilters); + return this; + } + + /** + * Set the tokenFilters property: The token filters for the index. + * + * @param tokenFilters the tokenFilters value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setTokenFilters(List tokenFilters) { this.tokenFilters = tokenFilters; return this; @@ -320,6 +395,18 @@ public List getCharFilters() { * @param charFilters the charFilters value to set. * @return the SearchIndex object itself. */ + public SearchIndex setCharFilters(CharFilter... charFilters) { + this.charFilters = (charFilters == null) ? null : Arrays.asList(charFilters); + return this; + } + + /** + * Set the charFilters property: The character filters for the index. + * + * @param charFilters the charFilters value to set. + * @return the SearchIndex object itself. + */ + @JsonSetter public SearchIndex setCharFilters(List charFilters) { this.charFilters = charFilters; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexer.java index 58d0fc9e5fc9..9a46b807fb4e 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexer.java @@ -6,6 +6,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -259,6 +262,19 @@ public List getFieldMappings() { * @param fieldMappings the fieldMappings value to set. * @return the SearchIndexer object itself. */ + public SearchIndexer setFieldMappings(FieldMapping... fieldMappings) { + this.fieldMappings = (fieldMappings == null) ? null : Arrays.asList(fieldMappings); + return this; + } + + /** + * Set the fieldMappings property: Defines mappings between fields in the + * data source and corresponding target fields in the index. + * + * @param fieldMappings the fieldMappings value to set. + * @return the SearchIndexer object itself. + */ + @JsonSetter public SearchIndexer setFieldMappings(List fieldMappings) { this.fieldMappings = fieldMappings; return this; @@ -281,6 +297,19 @@ public List getOutputFieldMappings() { * @param outputFieldMappings the outputFieldMappings value to set. * @return the SearchIndexer object itself. */ + public SearchIndexer setOutputFieldMappings(FieldMapping... outputFieldMappings) { + this.outputFieldMappings = (outputFieldMappings == null) ? null : Arrays.asList(outputFieldMappings); + return this; + } + + /** + * Set the outputFieldMappings property: Output field mappings are applied + * after enrichment and immediately before indexing. + * + * @param outputFieldMappings the outputFieldMappings value to set. + * @return the SearchIndexer object itself. + */ + @JsonSetter public SearchIndexer setOutputFieldMappings(List outputFieldMappings) { this.outputFieldMappings = outputFieldMappings; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerSkillset.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerSkillset.java index 6283f51f1943..ed5144112736 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerSkillset.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/SearchIndexerSkillset.java @@ -6,6 +6,9 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.Arrays; import java.util.List; /** @@ -110,6 +113,18 @@ public List getSkills() { * @param skills the skills value to set. * @return the SearchIndexerSkillset object itself. */ + public SearchIndexerSkillset setSkills(SearchIndexerSkill... skills) { + this.skills = (skills == null) ? null : Arrays.asList(skills); + return this; + } + + /** + * Set the skills property: A list of skills in the skillset. + * + * @param skills the skills value to set. + * @return the SearchIndexerSkillset object itself. + */ + @JsonSetter public SearchIndexerSkillset setSkills(List skills) { this.skills = skills; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopAnalyzer.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopAnalyzer.java index 98d10d80a5ed..34cd38efd123 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopAnalyzer.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopAnalyzer.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -49,6 +52,18 @@ public List getStopwords() { * @param stopwords the stopwords value to set. * @return the StopAnalyzer object itself. */ + public StopAnalyzer setStopwords(String... stopwords) { + this.stopwords = (stopwords == null) ? null : Arrays.asList(stopwords); + return this; + } + + /** + * Set the stopwords property: A list of stopwords. + * + * @param stopwords the stopwords value to set. + * @return the StopAnalyzer object itself. + */ + @JsonSetter public StopAnalyzer setStopwords(List stopwords) { this.stopwords = stopwords; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopwordsTokenFilter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopwordsTokenFilter.java index 4cddb34d8d5e..d7179cd3706a 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopwordsTokenFilter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/StopwordsTokenFilter.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -78,6 +81,19 @@ public List getStopwords() { * @param stopwords the stopwords value to set. * @return the StopwordsTokenFilter object itself. */ + public StopwordsTokenFilter setStopwords(String... stopwords) { + this.stopwords = (stopwords == null) ? null : Arrays.asList(stopwords); + return this; + } + + /** + * Set the stopwords property: The list of stopwords. This property and the + * stopwords list property cannot both be set. + * + * @param stopwords the stopwords value to set. + * @return the StopwordsTokenFilter object itself. + */ + @JsonSetter public StopwordsTokenFilter setStopwords(List stopwords) { this.stopwords = stopwords; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WordDelimiterTokenFilter.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WordDelimiterTokenFilter.java index 99a66624dd1f..aed639ef9c55 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WordDelimiterTokenFilter.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/indexes/models/WordDelimiterTokenFilter.java @@ -5,8 +5,11 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + +import java.util.Arrays; import java.util.List; /** @@ -329,6 +332,19 @@ public List getProtectedWords() { * @param protectedWords the protectedWords value to set. * @return the WordDelimiterTokenFilter object itself. */ + public WordDelimiterTokenFilter setProtectedWords(String... protectedWords) { + this.protectedWords = (protectedWords == null) ? null : Arrays.asList(protectedWords); + return this; + } + + /** + * Set the protectedWords property: A list of tokens to protect from being + * delimited. + * + * @param protectedWords the protectedWords value to set. + * @return the WordDelimiterTokenFilter object itself. + */ + @JsonSetter public WordDelimiterTokenFilter setProtectedWords(List protectedWords) { this.protectedWords = protectedWords; return this; diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/AutocompleteOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/AutocompleteOptions.java index 37bf316d380b..482d69a7c1d0 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/AutocompleteOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/AutocompleteOptions.java @@ -254,7 +254,7 @@ public List getSearchFields() { * @return the AutocompleteOptions object itself. */ public AutocompleteOptions setSearchFields(String... searchFields) { - this.searchFields = Arrays.asList(searchFields); + this.searchFields = (searchFields == null) ? null : Arrays.asList(searchFields); return this; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java index 8066adabd829..196505ee8d10 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SearchOptions.java @@ -193,7 +193,7 @@ public List getFacets() { * @return the SearchOptions object itself. */ public SearchOptions setFacets(String... facets) { - this.facets = Arrays.asList(facets); + this.facets = (facets == null) ? null : Arrays.asList(facets); return this; } @@ -237,7 +237,7 @@ public List getHighlightFields() { * @return the SearchOptions object itself. */ public SearchOptions setHighlightFields(String... highlightFields) { - this.highlightFields = Arrays.asList(highlightFields); + this.highlightFields = (highlightFields == null) ? null : Arrays.asList(highlightFields); return this; } @@ -347,7 +347,7 @@ public List getOrderBy() { * @return the SearchOptions object itself. */ public SearchOptions setOrderBy(String... orderBy) { - this.orderBy = Arrays.asList(orderBy); + this.orderBy = (orderBy == null) ? null : Arrays.asList(orderBy); return this; } @@ -399,7 +399,7 @@ public List getScoringParameters() { * @return the SearchOptions object itself. */ public SearchOptions setScoringParameters(ScoringParameter... scoringParameters) { - this.scoringParameters = Arrays.asList(scoringParameters); + this.scoringParameters = (scoringParameters == null) ? null : Arrays.asList(scoringParameters); return this; } @@ -451,7 +451,7 @@ public List getSearchFields() { * @return the SearchOptions object itself. */ public SearchOptions setSearchFields(String... searchFields) { - this.searchFields = Arrays.asList(searchFields); + this.searchFields = (searchFields == null) ? null : Arrays.asList(searchFields); return this; } @@ -497,7 +497,7 @@ public List getSelect() { * @return the SearchOptions object itself. */ public SearchOptions setSelect(String... select) { - this.select = Arrays.asList(select); + this.select = (select == null) ? null : Arrays.asList(select); return this; } diff --git a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SuggestOptions.java b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SuggestOptions.java index 4707580e2eb7..7268718ed886 100644 --- a/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SuggestOptions.java +++ b/sdk/search/azure-search-documents/src/main/java/com/azure/search/documents/models/SuggestOptions.java @@ -248,7 +248,7 @@ public List getOrderBy() { * @return the SuggestOptions object itself. */ public SuggestOptions setOrderBy(String... orderBy) { - this.orderBy = Arrays.asList(orderBy); + this.orderBy = (orderBy == null) ? null : Arrays.asList(orderBy); return this; } @@ -272,7 +272,7 @@ public List getSearchFields() { * @return the SuggestOptions object itself. */ public SuggestOptions setSearchFields(String... searchFields) { - this.searchFields = Arrays.asList(searchFields); + this.searchFields = (searchFields == null) ? null : Arrays.asList(searchFields); return this; } @@ -294,7 +294,7 @@ public List getSelect() { * @return the SuggestOptions object itself. */ public SuggestOptions setSelect(String... select) { - this.select = Arrays.asList(select); + this.select = (select == null) ? null : Arrays.asList(select); return this; } diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/IndexAndServiceStatisticsExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/IndexAndServiceStatisticsExample.java index 3decd86005df..186cd8260634 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/IndexAndServiceStatisticsExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/IndexAndServiceStatisticsExample.java @@ -42,8 +42,8 @@ public class IndexAndServiceStatisticsExample { /** - * From the Azure portal, get your Azure Cognitive Search service name and API key and - * populate ADMIN_KEY and SEARCH_SERVICE_NAME. + * From the Azure portal, get your Azure Cognitive Search service name and API key and populate ADMIN_KEY and + * SEARCH_SERVICE_NAME. */ private static final String ENDPOINT = Configuration.getGlobalConfiguration().get("AZURE_COGNITIVE_SEARCH_ENDPOINT"); private static final String ADMIN_KEY = Configuration.getGlobalConfiguration().get("AZURE_COGNITIVE_SEARCH_ADMIN_KEY"); @@ -286,8 +286,7 @@ private static SearchIndex createTestIndex() { .setScoringProfiles(Arrays.asList( new ScoringProfile("MyProfile") .setFunctionAggregation(ScoringFunctionAggregation.AVERAGE) - .setFunctions(Arrays.asList( - new MagnitudeScoringFunction("Rating", 2.0, + .setFunctions(new MagnitudeScoringFunction("Rating", 2.0, new MagnitudeScoringParameters(1, 4) .setShouldBoostBeyondRangeByConstant(true)) .setInterpolation(ScoringFunctionInterpolation.CONSTANT), @@ -297,36 +296,30 @@ private static SearchIndex createTestIndex() { new FreshnessScoringFunction("LastRenovationDate", 1.1, new FreshnessScoringParameters(Duration.ofDays(365))) .setInterpolation(ScoringFunctionInterpolation.LOGARITHMIC) - )) + ) .setTextWeights(new TextWeights(weights)), new ScoringProfile("ProfileTwo") .setFunctionAggregation(ScoringFunctionAggregation.MAXIMUM) - .setFunctions(Collections.singletonList( - new TagScoringFunction("Tags", 1.5, new TagScoringParameters("MyTags")) - .setInterpolation(ScoringFunctionInterpolation.LINEAR) - )), + .setFunctions(new TagScoringFunction("Tags", 1.5, new TagScoringParameters("MyTags")) + .setInterpolation(ScoringFunctionInterpolation.LINEAR) + ), new ScoringProfile("ProfileThree") .setFunctionAggregation(ScoringFunctionAggregation.MINIMUM) - .setFunctions(Collections.singletonList( - new MagnitudeScoringFunction("Rating", 3.0, - new MagnitudeScoringParameters(0, 10) + .setFunctions(new MagnitudeScoringFunction("Rating", 3.0, + new MagnitudeScoringParameters(0, 10) .setShouldBoostBeyondRangeByConstant(false)) - .setInterpolation(ScoringFunctionInterpolation.QUADRATIC) - )), + .setInterpolation(ScoringFunctionInterpolation.QUADRATIC) + ), new ScoringProfile("ProfileFour") .setFunctionAggregation(ScoringFunctionAggregation.FIRST_MATCHING) - .setFunctions(Collections.singletonList( - new MagnitudeScoringFunction("Rating", 3.14, - new MagnitudeScoringParameters(1, 5) + .setFunctions(new MagnitudeScoringFunction("Rating", 3.14, + new MagnitudeScoringParameters(1, 5) .setShouldBoostBeyondRangeByConstant(false)) - .setInterpolation(ScoringFunctionInterpolation.CONSTANT) - )) - )) + .setInterpolation(ScoringFunctionInterpolation.CONSTANT)))) .setDefaultScoringProfile("MyProfile") .setCorsOptions(new CorsOptions(Arrays.asList("http://tempuri.org", "http://localhost:80")) .setMaxAgeInSeconds(60L)) - .setSuggesters(Collections.singletonList(new SearchSuggester("FancySuggester", - Collections.singletonList("HotelName")))); + .setSuggesters(new SearchSuggester("FancySuggester", Collections.singletonList("HotelName"))); } /** diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/RefineSearchCapabilitiesExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/RefineSearchCapabilitiesExample.java index 2c1ccc0ab7be..88ce4b28826b 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/RefineSearchCapabilitiesExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/RefineSearchCapabilitiesExample.java @@ -129,7 +129,7 @@ private static void addSynonymMapToIndex(SearchIndexClient client) { SearchIndex index = client.getIndex(INDEX_NAME); List fields = index.getFields(); - fields.get(1).setSynonymMapNames(Collections.singletonList(synonymMapName)); + fields.get(1).setSynonymMapNames(synonymMapName); index.setFields(fields); client.createOrUpdateIndex(index); diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/SynonymMapsCreateExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/SynonymMapsCreateExample.java index 09dd900c513d..a18cb4d807cf 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/SynonymMapsCreateExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/SynonymMapsCreateExample.java @@ -13,7 +13,6 @@ import com.azure.search.documents.indexes.models.SynonymMap; import java.util.Arrays; -import java.util.Collections; /** * This example shows how to create an index with a synonym map @@ -59,7 +58,7 @@ private static void assignSynonymMapToIndex(String synonymMapName) { new SearchField("HotelId", SearchFieldDataType.STRING) .setKey(true), new SearchField("HotelName", SearchFieldDataType.STRING) - .setSynonymMapNames(Collections.singletonList(synonymMapName)) + .setSynonymMapNames(synonymMapName) )); } } diff --git a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java index e5b6d8c8a8b8..c6acd454d1b8 100644 --- a/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java +++ b/sdk/search/azure-search-documents/src/samples/java/com/azure/search/documents/indexes/LifecycleSetupExample.java @@ -167,8 +167,7 @@ private static SearchIndex createIndex(SearchIndexClient client) { SearchIndex index = new SearchIndex(INDEX_NAME, fields); // Set Suggester - index.setSuggesters(Collections.singletonList(new SearchSuggester(SUGGESTER_NAME, - Collections.singletonList("Tags")))); + index.setSuggesters(new SearchSuggester(SUGGESTER_NAME, Collections.singletonList("Tags"))); return client.createOrUpdateIndex(index); } diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/IndexingSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/IndexingSyncTests.java index e4e1a084bb13..0659cf655c69 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/IndexingSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/IndexingSyncTests.java @@ -333,9 +333,7 @@ public void indexWithInvalidDocumentThrowsException() { public void canUseIndexWithReservedName() { String indexName = "prototype"; SearchIndex indexWithReservedName = new SearchIndex(indexName) - .setFields(Collections.singletonList(new SearchField("ID", SearchFieldDataType.STRING) - .setKey(Boolean.TRUE) - )); + .setFields(new SearchField("ID", SearchFieldDataType.STRING).setKey(Boolean.TRUE)); SearchIndexClient searchIndexClient = getSearchIndexClientBuilder().buildClient(); searchIndexClient.createOrUpdateIndex(indexWithReservedName); diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchSyncTests.java index 3498f1e13012..189640b88278 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchSyncTests.java @@ -753,7 +753,7 @@ public void canSearchWithSynonyms() { SearchIndex hotelsIndex = searchIndexClient.getIndex(client.getIndexName()); hotelsIndex.getFields().stream() .filter(f -> fieldName.equals(f.getName())) - .findFirst().get().setSynonymMapNames(Collections.singletonList(synonymMapToDelete)); + .findFirst().get().setSynonymMapNames(synonymMapToDelete); // Update the index with the SynonymMap searchIndexClient.createOrUpdateIndex(hotelsIndex); diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java index a4b3d6fc0703..883877dcba9d 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/SearchTestBase.java @@ -197,187 +197,168 @@ protected SearchIndex createTestIndex(String indexName) { weights.put("Category", 2.0); String searchIndexName = indexName == null ? randomIndexName(HOTEL_INDEX_NAME) : indexName; return new SearchIndex(searchIndexName, Arrays.asList( - new SearchField("HotelId", SearchFieldDataType.STRING) - .setKey(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("HotelName", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Description", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setAnalyzerName(LexicalAnalyzerName.EN_LUCENE) - .setHidden(Boolean.FALSE), - new SearchField("DescriptionFr", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setAnalyzerName(LexicalAnalyzerName.FR_LUCENE) - .setHidden(Boolean.FALSE), - new SearchField("Description_Custom", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setSearchAnalyzerName(LexicalAnalyzerName.STOP) - .setIndexAnalyzerName(LexicalAnalyzerName.STOP) - .setHidden(Boolean.FALSE), - new SearchField("Category", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Tags", SearchFieldDataType.collection(SearchFieldDataType.STRING)) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("ParkingIncluded", SearchFieldDataType.BOOLEAN) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("SmokingAllowed", SearchFieldDataType.BOOLEAN) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("LastRenovationDate", SearchFieldDataType.DATE_TIME_OFFSET) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Rating", SearchFieldDataType.INT32) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Address", SearchFieldDataType.COMPLEX) - .setFields(Arrays.asList( - new SearchField("StreetAddress", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("City", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("StateProvince", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Country", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("PostalCode", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE) - ) - ), - new SearchField("Location", SearchFieldDataType.GEOGRAPHY_POINT) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Rooms", SearchFieldDataType.collection(SearchFieldDataType.COMPLEX)) - .setFields(Arrays.asList( - new SearchField("Description", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setAnalyzerName(LexicalAnalyzerName.EN_LUCENE), - new SearchField("DescriptionFr", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setAnalyzerName(LexicalAnalyzerName.FR_LUCENE) - .setHidden(Boolean.FALSE), - new SearchField("Type", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("BaseRate", SearchFieldDataType.DOUBLE) - .setKey(Boolean.FALSE) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("BedOptions", SearchFieldDataType.STRING) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("SleepsCount", SearchFieldDataType.INT32) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("SmokingAllowed", SearchFieldDataType.BOOLEAN) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE), - new SearchField("Tags", SearchFieldDataType.collection(SearchFieldDataType.STRING)) - .setSearchable(Boolean.TRUE) - .setFilterable(Boolean.TRUE) - .setFacetable(Boolean.TRUE) - .setHidden(Boolean.FALSE) - ) - ), - new SearchField("TotalGuests", SearchFieldDataType.INT64) - .setFilterable(Boolean.TRUE) - .setSortable(Boolean.TRUE) - .setFacetable(Boolean.TRUE), - new SearchField("ProfitMargin", SearchFieldDataType.DOUBLE) - ) - ) - .setScoringProfiles(Arrays.asList( - new ScoringProfile("MyProfile") - .setFunctionAggregation(ScoringFunctionAggregation.AVERAGE) - .setFunctions(Arrays.asList( - new MagnitudeScoringFunction("Rating", 2.0, - new MagnitudeScoringParameters(1, 4) - .setShouldBoostBeyondRangeByConstant(true)) - .setInterpolation(ScoringFunctionInterpolation.CONSTANT), - new DistanceScoringFunction("Location", 1.5, - new DistanceScoringParameters("Loc", 5)) - .setInterpolation(ScoringFunctionInterpolation.LINEAR), - new FreshnessScoringFunction("LastRenovationDate", 1.1, - new FreshnessScoringParameters(Duration.ofDays(365))) - .setInterpolation(ScoringFunctionInterpolation.LOGARITHMIC) - )) - .setTextWeights(new TextWeights(weights)), - new ScoringProfile("ProfileTwo") - .setFunctionAggregation(ScoringFunctionAggregation.MAXIMUM) - .setFunctions(Collections.singletonList( - new TagScoringFunction("Tags", 1.5, - new TagScoringParameters("MyTags")) - .setInterpolation(ScoringFunctionInterpolation.LINEAR) - )), - new ScoringProfile("ProfileThree") - .setFunctionAggregation(ScoringFunctionAggregation.MINIMUM) - .setFunctions(Collections.singletonList( - new MagnitudeScoringFunction("Rating", 3.0, - new MagnitudeScoringParameters(0, 10) - .setShouldBoostBeyondRangeByConstant(false)) - .setInterpolation(ScoringFunctionInterpolation.QUADRATIC) - )), - new ScoringProfile("ProfileFour") - .setFunctionAggregation(ScoringFunctionAggregation.FIRST_MATCHING) - .setFunctions(Collections.singletonList( - new MagnitudeScoringFunction("Rating", 3.14, - new MagnitudeScoringParameters(1, 5) - .setShouldBoostBeyondRangeByConstant(false)) - .setInterpolation(ScoringFunctionInterpolation.CONSTANT) - )) - )) - .setDefaultScoringProfile("MyProfile") + new SearchField("HotelId", SearchFieldDataType.STRING) + .setKey(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("HotelName", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Description", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setAnalyzerName(LexicalAnalyzerName.EN_LUCENE) + .setHidden(Boolean.FALSE), + new SearchField("DescriptionFr", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setAnalyzerName(LexicalAnalyzerName.FR_LUCENE) + .setHidden(Boolean.FALSE), + new SearchField("Description_Custom", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setSearchAnalyzerName(LexicalAnalyzerName.STOP) + .setIndexAnalyzerName(LexicalAnalyzerName.STOP) + .setHidden(Boolean.FALSE), + new SearchField("Category", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Tags", SearchFieldDataType.collection(SearchFieldDataType.STRING)) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("ParkingIncluded", SearchFieldDataType.BOOLEAN) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("SmokingAllowed", SearchFieldDataType.BOOLEAN) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("LastRenovationDate", SearchFieldDataType.DATE_TIME_OFFSET) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Rating", SearchFieldDataType.INT32) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Address", SearchFieldDataType.COMPLEX) + .setFields(new SearchField("StreetAddress", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("City", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("StateProvince", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Country", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("PostalCode", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE)), + new SearchField("Location", SearchFieldDataType.GEOGRAPHY_POINT) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Rooms", SearchFieldDataType.collection(SearchFieldDataType.COMPLEX)) + .setFields(new SearchField("Description", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setAnalyzerName(LexicalAnalyzerName.EN_LUCENE), + new SearchField("DescriptionFr", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setAnalyzerName(LexicalAnalyzerName.FR_LUCENE) + .setHidden(Boolean.FALSE), + new SearchField("Type", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("BaseRate", SearchFieldDataType.DOUBLE) + .setKey(Boolean.FALSE) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("BedOptions", SearchFieldDataType.STRING) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("SleepsCount", SearchFieldDataType.INT32) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("SmokingAllowed", SearchFieldDataType.BOOLEAN) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE), + new SearchField("Tags", SearchFieldDataType.collection(SearchFieldDataType.STRING)) + .setSearchable(Boolean.TRUE) + .setFilterable(Boolean.TRUE) + .setFacetable(Boolean.TRUE) + .setHidden(Boolean.FALSE)), + new SearchField("TotalGuests", SearchFieldDataType.INT64) + .setFilterable(Boolean.TRUE) + .setSortable(Boolean.TRUE) + .setFacetable(Boolean.TRUE), + new SearchField("ProfitMargin", SearchFieldDataType.DOUBLE) + )).setScoringProfiles(new ScoringProfile("MyProfile") + .setFunctionAggregation(ScoringFunctionAggregation.AVERAGE) + .setFunctions(new MagnitudeScoringFunction("Rating", 2.0, + new MagnitudeScoringParameters(1, 4) + .setShouldBoostBeyondRangeByConstant(true)) + .setInterpolation(ScoringFunctionInterpolation.CONSTANT), + new DistanceScoringFunction("Location", 1.5, + new DistanceScoringParameters("Loc", 5)) + .setInterpolation(ScoringFunctionInterpolation.LINEAR), + new FreshnessScoringFunction("LastRenovationDate", 1.1, + new FreshnessScoringParameters(Duration.ofDays(365))) + .setInterpolation(ScoringFunctionInterpolation.LOGARITHMIC)) + .setTextWeights(new TextWeights(weights)), + new ScoringProfile("ProfileTwo") + .setFunctionAggregation(ScoringFunctionAggregation.MAXIMUM) + .setFunctions(new TagScoringFunction("Tags", 1.5, + new TagScoringParameters("MyTags")) + .setInterpolation(ScoringFunctionInterpolation.LINEAR)), + new ScoringProfile("ProfileThree") + .setFunctionAggregation(ScoringFunctionAggregation.MINIMUM) + .setFunctions(new MagnitudeScoringFunction("Rating", 3.0, + new MagnitudeScoringParameters(0, 10) + .setShouldBoostBeyondRangeByConstant(false)) + .setInterpolation(ScoringFunctionInterpolation.QUADRATIC)), + new ScoringProfile("ProfileFour") + .setFunctionAggregation(ScoringFunctionAggregation.FIRST_MATCHING) + .setFunctions(new MagnitudeScoringFunction("Rating", 3.14, + new MagnitudeScoringParameters(1, 5) + .setShouldBoostBeyondRangeByConstant(false)) + .setInterpolation(ScoringFunctionInterpolation.CONSTANT)) + ).setDefaultScoringProfile("MyProfile") .setCorsOptions(new CorsOptions(Arrays.asList("http://tempuri.org", "http://localhost:80")) .setMaxAgeInSeconds(60L)) - .setSuggesters(Collections.singletonList(new SearchSuggester("FancySuggester", - Collections.singletonList("HotelName")))); + .setSuggesters(new SearchSuggester("FancySuggester", Collections.singletonList("HotelName"))); } protected SearchIndexerDataSourceConnection createTestSqlDataSourceObject() { diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/CustomAnalyzerSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/CustomAnalyzerSyncTests.java index 0c08d69fb38c..e8580d40f85d 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/CustomAnalyzerSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/CustomAnalyzerSyncTests.java @@ -127,13 +127,9 @@ public void canSearchWithCustomAnalyzer() { .setAnalyzerName(customLexicalAnalyzerName) .setSearchable(true) )) - .setAnalyzers(Collections.singletonList( - new CustomAnalyzer(customLexicalAnalyzerName.toString(), LexicalTokenizerName.STANDARD) - .setCharFilters(Collections.singletonList(customCharFilterName)) - )) - .setCharFilters(Collections.singletonList( - new PatternReplaceCharFilter(customCharFilterName.toString(), "@", "_") - )); + .setAnalyzers(new CustomAnalyzer(customLexicalAnalyzerName.toString(), LexicalTokenizerName.STANDARD) + .setCharFilters(customCharFilterName)) + .setCharFilters(new PatternReplaceCharFilter(customCharFilterName.toString(), "@", "_")); searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -198,8 +194,8 @@ public void canAnalyze() { assertFalse(iterator.hasNext()); request = new AnalyzeTextOptions("One's ", LexicalTokenizerName.WHITESPACE) - .setTokenFilters(Collections.singletonList(TokenFilterName.APOSTROPHE)) - .setCharFilters(Collections.singletonList(CharFilterName.HTML_STRIP)); + .setTokenFilters(TokenFilterName.APOSTROPHE) + .setCharFilters(CharFilterName.HTML_STRIP); results = searchIndexClient.analyzeText(index.getName(), request); // End offset is based on the original token, not the one emitted by the filters. iterator = results.iterator(); @@ -230,15 +226,14 @@ public void canAnalyzeWithAllPossibleNames() { .forEach(r -> searchIndexClient.analyzeText(index.getName(), r)); AnalyzeTextOptions request = new AnalyzeTextOptions("One two", LexicalTokenizerName.WHITESPACE) - .setTokenFilters(new ArrayList<>(TokenFilterName.values())) - .setCharFilters(new ArrayList<>(CharFilterName.values())); + .setTokenFilters(TokenFilterName.values().toArray(new TokenFilterName[0])) + .setCharFilters(CharFilterName.values().toArray(new CharFilterName[0])); searchIndexClient.analyzeText(index.getName(), request); } @Test public void addingCustomAnalyzerThrowsHttpExceptionByDefault() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList(new StopAnalyzer("a1"))); + SearchIndex index = createTestIndex(null).setAnalyzers(new StopAnalyzer("a1")); searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -253,8 +248,7 @@ public void addingCustomAnalyzerThrowsHttpExceptionByDefault() { @Test public void canAddCustomAnalyzerWithIndexDowntime() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList(new StopAnalyzer("a1"))); + SearchIndex index = createTestIndex(null).setAnalyzers(new StopAnalyzer("a1")); searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -302,12 +296,11 @@ public void canUseAllAnalysisComponentNames() { @Test public void canUseAllRegexFlagsAnalyzer() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList(new PatternAnalyzer(generateName()) - .setStopwords(Arrays.asList("stop1", "stop2")) - .setLowerCaseTerms(true) - .setPattern(".*") - .setFlags(new ArrayList<>(RegexFlags.values())))); + SearchIndex index = createTestIndex(null).setAnalyzers(new PatternAnalyzer(generateName()) + .setStopwords("stop1", "stop2") + .setLowerCaseTerms(true) + .setPattern(".*") + .setFlags(new ArrayList<>(RegexFlags.values()))); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -318,7 +311,7 @@ public void canUseAllRegexFlagsAnalyzer() { @Test public void canUseAllRegexFlagsNullAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(null); + .setAnalyzers((List) null); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -339,23 +332,16 @@ public void canUseAllRegexFlagsEmptyAnalyzer() { @Test public void canUseAllRegexFlagsNullNameAnalyzer() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(null) - )); + SearchIndex index = createTestIndex(null).setAnalyzers(new PatternAnalyzer(null)); - assertThrows(IllegalArgumentException.class, () -> { - searchIndexClient.createIndex(index); - }, "Missing required property name in model LexicalAnalyzer"); + assertThrows(IllegalArgumentException.class, () -> + searchIndexClient.createIndex(index), "Missing required property name in model LexicalAnalyzer"); } @Test public void canUseAllRegexFlagsEmptyNameAnalyzer() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer("") - )); + SearchIndex index = createTestIndex(null).setAnalyzers(new PatternAnalyzer("")); assertHttpResponseException( () -> searchIndexClient.createIndex(index), @@ -367,9 +353,7 @@ public void canUseAllRegexFlagsEmptyNameAnalyzer() { @Test public void canUseAllRegexFlagsNullLowerCaseAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(generateName()).setLowerCaseTerms(null) - )); + .setAnalyzers(new PatternAnalyzer(generateName()).setLowerCaseTerms(null)); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -380,9 +364,7 @@ public void canUseAllRegexFlagsNullLowerCaseAnalyzer() { @Test public void canUseAllRegexFlagsNullPatternAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(generateName()).setPattern(null) - )); + .setAnalyzers(new PatternAnalyzer(generateName()).setPattern(null)); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -393,22 +375,7 @@ public void canUseAllRegexFlagsNullPatternAnalyzer() { @Test public void canUseAllRegexFlagsEmptyPatternAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(generateName()).setPattern("")) - ); - - SearchIndex createdIndex = searchIndexClient.createIndex(index); - indexesToCleanup.add(index.getName()); - - assertAnalysisComponentsEqual(index, createdIndex); - } - - @Test - public void canUseAllRegexFlagsNullFlagsAnalyzer() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(generateName()).setFlags(null)) - ); + .setAnalyzers(new PatternAnalyzer(generateName()).setPattern("")); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -419,9 +386,7 @@ public void canUseAllRegexFlagsNullFlagsAnalyzer() { @Test public void canUseAllRegexFlagsEmptyFlagsAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList( - new PatternAnalyzer(generateName()).setFlags(new ArrayList<>())) - ); + .setAnalyzers(new PatternAnalyzer(generateName()).setFlags()); assertHttpResponseException( () -> searchIndexClient.createIndex(index), @@ -430,23 +395,10 @@ public void canUseAllRegexFlagsEmptyFlagsAnalyzer() { ); } - @Test - public void canUseAllRegexFlagsNullStopwordsAnalyzer() { - SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList(new PatternAnalyzer(generateName()) - .setStopwords(null))); - - SearchIndex createdIndex = searchIndexClient.createIndex(index); - indexesToCleanup.add(index.getName()); - - assertAnalysisComponentsEqual(index, createdIndex); - } - @Test public void canUseAllRegexFlagsEmptyStopwordsAnalyzer() { SearchIndex index = createTestIndex(null) - .setAnalyzers(Collections.singletonList(new PatternAnalyzer(generateName()) - .setStopwords(new ArrayList<>()))); + .setAnalyzers(new PatternAnalyzer(generateName()).setStopwords()); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -457,10 +409,10 @@ public void canUseAllRegexFlagsEmptyStopwordsAnalyzer() { @Test public void canUseAllRegexFlagsTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) + .setTokenizers(new PatternTokenizer(generateName()) .setPattern(".*") .setFlags(new ArrayList<>(RegexFlags.values())) - .setGroup(0))); + .setGroup(0)); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -471,7 +423,7 @@ public void canUseAllRegexFlagsTokenizer() { @Test public void canUseAllRegexFlagsNullTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(null); + .setTokenizers((List) null); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -493,19 +445,17 @@ public void canUseAllRegexFlagsEmptyTokenizer() { @Test public void canUseAllRegexFlagsNullNameTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(null))); + .setTokenizers(new PatternTokenizer(null)); - assertThrows(IllegalArgumentException.class, () -> { - searchIndexClient.createIndex(index); - }, "Missing required property name in model SearchIndexer"); + assertThrows(IllegalArgumentException.class, () -> + searchIndexClient.createIndex(index), "Missing required property name in model SearchIndexer"); } @Test public void canUseAllRegexFlagsEmptyNameTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer("") - )); + .setTokenizers(new PatternTokenizer("")); assertHttpResponseException( () -> searchIndexClient.createIndex(index), @@ -517,8 +467,7 @@ public void canUseAllRegexFlagsEmptyNameTokenizer() { @Test public void canUseAllRegexFlagsNullPatternTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) - .setPattern(null))); + .setTokenizers(new PatternTokenizer(generateName()).setPattern(null)); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -529,35 +478,18 @@ public void canUseAllRegexFlagsNullPatternTokenizer() { @Test public void canUseAllRegexFlagsEmptyPatternTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) - .setPattern("")) - ); - - SearchIndex createdIndex = searchIndexClient.createIndex(index); - indexesToCleanup.add(index.getName()); - - assertAnalysisComponentsEqual(index, createdIndex); - } - - @Test - public void canUseAllRegexFlagsNullFlagsTokenizer() { - SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) - .setFlags(null))); + .setTokenizers(new PatternTokenizer(generateName()).setPattern("")); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); assertAnalysisComponentsEqual(index, createdIndex); - System.out.println(RegexFlags.values()); } @Test public void canUseAllRegexFlagsEmptyFlagsTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) - .setFlags(new ArrayList<>())) - ); + .setTokenizers(new PatternTokenizer(generateName()).setFlags()); assertHttpResponseException( () -> searchIndexClient.createIndex(index), @@ -569,8 +501,7 @@ public void canUseAllRegexFlagsEmptyFlagsTokenizer() { @Test public void canUseAllRegexFlagsNullGroupTokenizer() { SearchIndex index = createTestIndex(null) - .setTokenizers(Collections.singletonList(new PatternTokenizer(generateName()) - .setGroup(null))); + .setTokenizers(new PatternTokenizer(generateName()).setGroup(null)); SearchIndex createdIndex = searchIndexClient.createIndex(index); indexesToCleanup.add(index.getName()); @@ -672,8 +603,7 @@ List prepareIndexesWithAllAnalysisComponentOptions() { new EdgeNGramTokenizer(generateName()) .setMinGram(1) .setMaxGram(2) - .setTokenChars(Arrays.asList(TokenCharacterKind.values())) - ); + .setTokenChars(TokenCharacterKind.values())); tokenizers.addAll( Arrays.stream(MicrosoftStemmingTokenizerLanguage.values()) .map(mtl -> new MicrosoftLanguageStemmingTokenizer(generateName()) @@ -688,7 +618,7 @@ List prepareIndexesWithAllAnalysisComponentOptions() { // Set token filters List tokenFilters = new ArrayList<>(); tokenFilters.add(new CjkBigramTokenFilter(generateName()) - .setIgnoreScripts(Arrays.asList(CjkBigramTokenFilterScripts.values())) + .setIgnoreScripts(CjkBigramTokenFilterScripts.values()) .setOutputUnigrams(true)); tokenFilters.addAll( Arrays.stream(EdgeNGramTokenFilterSide.values()) @@ -850,35 +780,34 @@ SearchIndex prepareIndexWithAllAnalysisComponentTypes() { final CharFilterName customCharFilterName = CharFilterName.fromString("my_charfilter"); return createTestIndex(null) - .setAnalyzers(Arrays.asList( + .setAnalyzers( new CustomAnalyzer(generateName(), customTokenizerName) - .setTokenFilters(Collections.singletonList(customTokenFilterName)) - .setCharFilters(Collections.singletonList(customCharFilterName)), + .setTokenFilters(customTokenFilterName) + .setCharFilters(customCharFilterName), new CustomAnalyzer(generateName(), LexicalTokenizerName.EDGE_NGRAM), new PatternAnalyzer(generateName()) .setLowerCaseTerms(false) .setPattern("abc") - .setFlags(Collections.singletonList(RegexFlags.DOT_ALL)) - .setStopwords(Collections.singletonList("the")), + .setFlags(RegexFlags.DOT_ALL) + .setStopwords("the"), new LuceneStandardAnalyzer(generateName()) .setMaxTokenLength(100) - .setStopwords(Collections.singletonList("the")), - new StopAnalyzer(generateName()) - .setStopwords(Collections.singletonList("the")), + .setStopwords("the"), new StopAnalyzer(generateName()) - )) - .setTokenizers(Arrays.asList( + .setStopwords("the"), + new StopAnalyzer(generateName())) + .setTokenizers( new EdgeNGramTokenizer(customTokenizerName.toString()) .setMinGram(1) .setMaxGram(2), new EdgeNGramTokenizer(generateName()) .setMinGram(2) .setMaxGram(4) - .setTokenChars(Collections.singletonList(TokenCharacterKind.LETTER)), + .setTokenChars(TokenCharacterKind.LETTER), new NGramTokenizer(generateName()) .setMinGram(2) .setMaxGram(4) - .setTokenChars(Collections.singletonList(TokenCharacterKind.LETTER)), + .setTokenChars(TokenCharacterKind.LETTER), new ClassicTokenizer(generateName()) .setMaxTokenLength(100), new KeywordTokenizer(generateName()) @@ -899,17 +828,16 @@ SearchIndex prepareIndexWithAllAnalysisComponentTypes() { .setNumberOfTokensToSkip(2), new PatternTokenizer(generateName()) .setPattern(".*") - .setFlags(Collections.singletonList(RegexFlags.MULTILINE)) + .setFlags(RegexFlags.MULTILINE) .setGroup(0), new LuceneStandardTokenizer(generateName()) .setMaxTokenLength(100), new UaxUrlEmailTokenizer(generateName()) - .setMaxTokenLength(100) - )) - .setTokenFilters(Arrays.asList( + .setMaxTokenLength(100)) + .setTokenFilters( new CjkBigramTokenFilter(customTokenFilterName.toString()), // One custom token filter for CustomAnalyzer above. new CjkBigramTokenFilter(generateName()) - .setIgnoreScripts(Collections.singletonList(CjkBigramTokenFilterScripts.HAN)) + .setIgnoreScripts(CjkBigramTokenFilterScripts.HAN) .setOutputUnigrams(true), new CjkBigramTokenFilter(generateName()), new AsciiFoldingTokenFilter(generateName()) @@ -929,7 +857,7 @@ SearchIndex prepareIndexWithAllAnalysisComponentTypes() { .setMaxGram(10) .setSide(EdgeNGramTokenFilterSide.BACK), new ElisionTokenFilter(generateName()) - .setArticles(Collections.singletonList("a")), + .setArticles("a"), new ElisionTokenFilter(generateName()), new KeepTokenFilter(generateName(), Collections.singletonList("aloha")), new KeepTokenFilter(generateName(), Arrays.asList("e", "komo", "mai")), @@ -986,13 +914,11 @@ SearchIndex prepareIndexWithAllAnalysisComponentTypes() { .setPreserveOriginal(true) .setSplitOnNumerics(false) .setStemEnglishPossessive(false) - .setProtectedWords(Collections.singletonList("protected")))) - .setCharFilters(Arrays.asList( - new MappingCharFilter(customCharFilterName.toString(), + .setProtectedWords("protected")) + .setCharFilters(new MappingCharFilter(customCharFilterName.toString(), Collections.singletonList("a => b")), // One custom char filter for CustomeAnalyer above. new MappingCharFilter(generateName(), Arrays.asList("s => $", "S => $")), - new PatternReplaceCharFilter(generateName(), "abc", "123") - )); + new PatternReplaceCharFilter(generateName(), "abc", "123")); } SearchIndex createIndexWithSpecialDefaults() { diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java index 9f4363ffa40e..8506e195951a 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/IndexManagementSyncTests.java @@ -99,11 +99,8 @@ public void createIndexReturnsCorrectDefinitionWithResponse() { public void createIndexReturnsCorrectDefaultValues() { SearchIndex index = createTestIndex(null) .setCorsOptions(new CorsOptions(Collections.singletonList("*"))) - .setScoringProfiles(Collections.singletonList(new ScoringProfile("MyProfile") - .setFunctions(Collections.singletonList(new MagnitudeScoringFunction("Rating", 2.0, - new MagnitudeScoringParameters(1, 4))) - ) - )); + .setScoringProfiles(new ScoringProfile("MyProfile") + .setFunctions(new MagnitudeScoringFunction("Rating", 2.0, new MagnitudeScoringParameters(1, 4)))); SearchIndex indexResponse = client.createIndex(index); indexesToDelete.add(indexResponse.getName()); @@ -118,10 +115,7 @@ public void createIndexReturnsCorrectDefaultValues() { public void createIndexFailsWithUsefulMessageOnUserError() { String indexName = HOTEL_INDEX_NAME; SearchIndex index = new SearchIndex(indexName) - .setFields(Collections.singletonList( - new SearchField("HotelId", SearchFieldDataType.STRING) - .setKey(false) - )); + .setFields(new SearchField("HotelId", SearchFieldDataType.STRING).setKey(false)); String expectedMessage = String.format("The request is invalid. Details: index : Found 0 key fields in index '%s'. " + "Each index must have exactly one key field.", indexName); @@ -174,7 +168,7 @@ public void deleteIndexIfNotChangedWorksOnlyOnCurrentResource() { // Update the resource, the eTag will be changed SearchIndex updatedIndex = client.createOrUpdateIndexWithResponse(originalIndex - .setCorsOptions(new CorsOptions(Collections.singletonList("https://test.com/"))), false, false, + .setCorsOptions(new CorsOptions(Collections.singletonList("https://test.com/"))), false, false, Context.NONE) .getValue(); @@ -207,10 +201,7 @@ public void deleteIndexIfExistsWorksOnlyWhenResourceExists() { @Test public void deleteIndexIsIdempotent() { SearchIndex index = new SearchIndex(HOTEL_INDEX_NAME) - .setFields(Collections.singletonList( - new SearchField("HotelId", SearchFieldDataType.STRING) - .setKey(true) - )); + .setFields(new SearchField("HotelId", SearchFieldDataType.STRING).setKey(true)); Response deleteResponse = client.deleteIndexWithResponse(index, false, Context.NONE); assertEquals(HttpURLConnection.HTTP_NOT_FOUND, deleteResponse.getStatusCode()); @@ -288,8 +279,7 @@ public void canAddSynonymFieldProperty() { new SearchField("HotelId", SearchFieldDataType.STRING) .setKey(true), new SearchField("HotelName", SearchFieldDataType.STRING) - .setSynonymMapNames(Collections.singletonList(synonymMapName)) - )); + .setSynonymMapNames(synonymMapName))); SearchIndex createdIndex = client.createIndex(index); indexesToDelete.add(createdIndex.getName()); @@ -311,7 +301,7 @@ public void canUpdateSynonymFieldProperty() { // Create an index SearchIndex index = createTestIndex(null); SearchField hotelNameField = getFieldByName(index, "HotelName"); - hotelNameField.setSynonymMapNames(Collections.singletonList(synonymMapName)); + hotelNameField.setSynonymMapNames(synonymMapName); client.createIndex(index); indexesToDelete.add(index.getName()); @@ -361,7 +351,7 @@ public void canUpdateIndexDefinition() { SearchField tagsField = getFieldByName(existingIndex, "Description_Custom"); tagsField.setHidden(true) .setSearchAnalyzerName(LexicalAnalyzerName.WHITESPACE) - .setSynonymMapNames(Collections.singletonList(synonymMap.getName())); + .setSynonymMapNames(synonymMap.getName()); SearchField hotelWebSiteField = new SearchField("HotelWebsite", SearchFieldDataType.STRING) .setSearchable(Boolean.TRUE) @@ -388,9 +378,7 @@ public void canUpdateSuggesterWithNewIndexFields() { existingIndex.getFields().addAll(Arrays.asList( new SearchField("HotelAmenities", SearchFieldDataType.STRING), new SearchField("HotelRewards", SearchFieldDataType.STRING))); - existingIndex.setSuggesters(Collections.singletonList(new SearchSuggester("Suggestion", - Arrays.asList("HotelAmenities", "HotelRewards")) - )); + existingIndex.setSuggesters(new SearchSuggester("Suggestion", Arrays.asList("HotelAmenities", "HotelRewards"))); SearchIndex updatedIndex = client.createOrUpdateIndexWithResponse(existingIndex, true, false, Context.NONE).getValue(); @@ -405,9 +393,7 @@ public void createOrUpdateIndexThrowsWhenUpdatingSuggesterWithExistingIndexField SearchIndex existingIndex = client.getIndex(index.getName()); String existingFieldName = "Category"; - existingIndex.setSuggesters(Collections.singletonList(new SearchSuggester("Suggestion", - Collections.singletonList(existingFieldName)) - )); + existingIndex.setSuggesters(new SearchSuggester("Suggestion", Collections.singletonList(existingFieldName))); assertHttpResponseException( () -> client.createOrUpdateIndex(existingIndex), diff --git a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java index 7f33727e0961..1f88f93b504b 100644 --- a/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java +++ b/sdk/search/azure-search-documents/src/test/java/com/azure/search/documents/indexes/SkillsetManagementSyncTests.java @@ -122,10 +122,8 @@ public void createSkillsetReturnsCorrectDefinitionOcrEntity() { skillsetsToDelete.add(actualSkillset.getName()); assertObjectEquals(expectedSkillset, actualSkillset, true, "etag"); - List entityCategories = Arrays.asList( - EntityCategory.LOCATION, EntityCategory.ORGANIZATION, EntityCategory.PERSON); - - expectedSkillset = createTestSkillsetOcrEntity(entityCategories); + expectedSkillset = createTestSkillsetOcrEntity(Arrays.asList(EntityCategory.LOCATION, + EntityCategory.ORGANIZATION, EntityCategory.PERSON)); actualSkillset = client.createSkillset(expectedSkillset); skillsetsToDelete.add(actualSkillset.getName()); assertObjectEquals(expectedSkillset, actualSkillset, true, "etag"); @@ -612,7 +610,7 @@ SearchIndexerSkillset createTestSkillsetImageAnalysisKeyPhrase() { skills.add(new ImageAnalysisSkill(inputs, outputs) .setVisualFeatures(new ArrayList<>(VisualFeature.values())) - .setDetails(new ArrayList<>((ImageDetail.values()))) + .setDetails(new ArrayList<>(ImageDetail.values())) .setDefaultLanguageCode(ImageAnalysisSkillLanguage.EN) .setName("myimage") .setDescription("Tested image analysis skill") @@ -743,15 +741,13 @@ SearchIndexerSkillset createTestSkillsetConditional() { } SearchIndexerSkillset mutateSkillsInSkillset(SearchIndexerSkillset skillset) { - return skillset.setSkills(Collections.singletonList( - new KeyPhraseExtractionSkill(Collections - .singletonList(simpleInputFieldMappingEntry("text", "/document/mydescription/*/Tags/*")), - Collections.singletonList(createOutputFieldMappingEntry("keyPhrases", "myKeyPhrases"))) - .setDefaultLanguageCode(KeyPhraseExtractionSkillLanguage.EN) - .setName("mykeyphrases") - .setDescription("Tested Key Phrase skill") - .setContext(CONTEXT_VALUE) - )); + return skillset.setSkills(new KeyPhraseExtractionSkill(Collections + .singletonList(simpleInputFieldMappingEntry("text", "/document/mydescription/*/Tags/*")), + Collections.singletonList(createOutputFieldMappingEntry("keyPhrases", "myKeyPhrases"))) + .setDefaultLanguageCode(KeyPhraseExtractionSkillLanguage.EN) + .setName("mykeyphrases") + .setDescription("Tested Key Phrase skill") + .setContext(CONTEXT_VALUE)); } SearchIndexerSkillset createTestSkillsetOcrEntity(List categories) { @@ -945,7 +941,7 @@ SearchIndexerSkillset createSkillsetWithKeyPhraseExtractionDefaultSettings() { ); return new SearchIndexerSkillset(testResourceNamer.randomName("key-phrase-extraction-skillset", 48), - skills).setDescription("Skillset for testing default configuration"); + skills).setDescription("Skillset for testing default configuration"); } SearchIndexerSkillset createSkillsetWithMergeDefaultSettings() { diff --git a/sdk/search/tests.yml b/sdk/search/tests.yml index 4b3c335e3e50..f205c2721284 100644 --- a/sdk/search/tests.yml +++ b/sdk/search/tests.yml @@ -4,8 +4,8 @@ jobs: - template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml parameters: ServiceDirectory: search - Timeout: 120 - MaxParallel: 2 + Timeout: 60 + MaxParallel: 3 EnvVars: AZURE_TEST_MODE: LIVE Artifacts: