Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public class Analyzer extends GenericModel {
/**
* Schema for the name of the Apache Lucene analyzer to use for text indexing. The default value varies depending on
* the analyzer usage:
* * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query text
* index default_field the default is `standard`.
* * For search indexes the default is `standard`
* * For query text indexes the default is `keyword`
* * For a query text index default_field the default is `standard`.
*/
public interface Name {
/** classic. */
Expand Down Expand Up @@ -223,8 +224,9 @@ public Builder newBuilder() {
*
* Schema for the name of the Apache Lucene analyzer to use for text indexing. The default value varies depending on
* the analyzer usage:
* * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query text
* index default_field the default is `standard`.
* * For search indexes the default is `standard`
* * For query text indexes the default is `keyword`
* * For a query text index default_field the default is `standard`.
*
* @return the name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@
import java.util.List;
import java.util.Map;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;

/**
* Schema for a search analyzer configuration.
* Analyzer configuration for search indexes. The default and fields properties are only applicable for the `perfield`
* analyzer name.
*/
public class AnalyzerConfiguration extends GenericModel {

/**
* Schema for the name of the Apache Lucene analyzer to use for text indexing. The default value varies depending on
* the analyzer usage:
* * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query text
* index default_field the default is `standard`.
* * For search indexes the default is `standard`
* * For query text indexes the default is `keyword`
* * For a query text index default_field the default is `standard`.
*/
public interface Name {
/** classic. */
Expand Down Expand Up @@ -119,6 +122,8 @@ public interface Name {

protected String name;
protected List<String> stopwords;
@SerializedName("default")
protected Analyzer xDefault;
protected Map<String, Analyzer> fields;

/**
Expand All @@ -127,6 +132,7 @@ public interface Name {
public static class Builder {
private String name;
private List<String> stopwords;
private Analyzer xDefault;
private Map<String, Analyzer> fields;

/**
Expand All @@ -137,6 +143,7 @@ public static class Builder {
private Builder(AnalyzerConfiguration analyzerConfiguration) {
this.name = analyzerConfiguration.name;
this.stopwords = analyzerConfiguration.stopwords;
this.xDefault = analyzerConfiguration.xDefault;
this.fields = analyzerConfiguration.fields;
}

Expand Down Expand Up @@ -203,6 +210,17 @@ public Builder stopwords(List<String> stopwords) {
return this;
}

/**
* Set the xDefault.
*
* @param xDefault the xDefault
* @return the AnalyzerConfiguration builder
*/
public Builder xDefault(Analyzer xDefault) {
this.xDefault = xDefault;
return this;
}

/**
* Set the fields.
*
Expand All @@ -222,6 +240,7 @@ protected AnalyzerConfiguration(Builder builder) {
"name cannot be null");
name = builder.name;
stopwords = builder.stopwords;
xDefault = builder.xDefault;
fields = builder.fields;
}

Expand All @@ -239,8 +258,9 @@ public Builder newBuilder() {
*
* Schema for the name of the Apache Lucene analyzer to use for text indexing. The default value varies depending on
* the analyzer usage:
* * For search indexes the default is `standard` * For query text indexes the default is `keyword` * For a query text
* index default_field the default is `standard`.
* * For search indexes the default is `standard`
* * For query text indexes the default is `keyword`
* * For a query text index default_field the default is `standard`.
*
* @return the name
*/
Expand All @@ -259,6 +279,17 @@ public List<String> stopwords() {
return stopwords;
}

/**
* Gets the xDefault.
*
* Schema for a full text search analyzer.
*
* @return the xDefault
*/
public Analyzer xDefault() {
return xDefault;
}

/**
* Gets the fields.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
/**
* Schema for a `json` or `text` query index definition. Indexes of type `text` have additional configuration properties
* that do not apply to `json` indexes, these are:
* * `default_analyzer` - the default text analyzer to use * `default_field` - whether to index the text in all document
* fields and what analyzer to use for that purpose.
* * `default_analyzer` - the default text analyzer to use
* * `default_field` - whether to index the text in all document fields and what analyzer to use for that purpose.
*/
public class IndexDefinition extends GenericModel {

Expand Down Expand Up @@ -223,9 +223,10 @@ public List<IndexField> fields() {
*
* Whether to scan every document for arrays and store the length for each array found. Set the index_array_lengths
* field to false if:
* * You do not need to know the length of an array. * You do not use the `$size` operator. * The documents in your
* database are complex, or not completely under your control. As a result, it is difficult to estimate the impact of
* the extra processing that is needed to determine and store the arrays lengths.
* * You do not need to know the length of an array.
* * You do not use the `$size` operator.
* * The documents in your database are complex, or not completely under your control. As a result, it is difficult to
* estimate the impact of the extra processing that is needed to determine and store the arrays lengths.
*
* @return the indexArrayLengths
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public String getDdoc() {
*
* Schema for a `json` or `text` query index definition. Indexes of type `text` have additional configuration
* properties that do not apply to `json` indexes, these are:
* * `default_analyzer` - the default text analyzer to use * `default_field` - whether to index the text in all
* document fields and what analyzer to use for that purpose.
* * `default_analyzer` - the default text analyzer to use
* * `default_field` - whether to index the text in all document fields and what analyzer to use for that purpose.
*
* @return the def
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public String db() {
*
* Schema for a `json` or `text` query index definition. Indexes of type `text` have additional configuration
* properties that do not apply to `json` indexes, these are:
* * `default_analyzer` - the default text analyzer to use * `default_field` - whether to index the text in all
* document fields and what analyzer to use for that purpose.
* * `default_analyzer` - the default text analyzer to use
* * `default_field` - whether to index the text in all document fields and what analyzer to use for that purpose.
*
* @return the index
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public Builder newBuilder() {
/**
* Gets the analyzer.
*
* Schema for a search analyzer configuration.
* Analyzer configuration for search indexes. The default and fields properties are only applicable for the `perfield`
* analyzer name.
*
* @return the analyzer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ public void testPutDesignDocument() throws Exception {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("standard")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ public void testDeleteDesignDocumentNoOptions() throws Throwable {
@Test
public void testGetDesignDocumentWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}], \"autoupdate\": true, \"filters\": {\"mapKey\": \"inner\"}, \"indexes\": {\"mapKey\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"], \"fields\": {\"mapKey\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}}}, \"index\": \"index\"}}, \"language\": \"javascript\", \"options\": {\"partitioned\": false}, \"validate_doc_update\": \"validateDocUpdate\", \"views\": {\"mapKey\": {\"map\": \"map\", \"reduce\": \"reduce\"}}}";
String mockResponseBody = "{\"_attachments\": {\"mapKey\": {\"content_type\": \"contentType\", \"data\": \"VGhpcyBpcyBhIG1vY2sgYnl0ZSBhcnJheSB2YWx1ZS4=\", \"digest\": \"digest\", \"encoded_length\": 0, \"encoding\": \"encoding\", \"follows\": false, \"length\": 0, \"revpos\": 1, \"stub\": true}}, \"_conflicts\": [\"conflicts\"], \"_deleted\": false, \"_deleted_conflicts\": [\"deletedConflicts\"], \"_id\": \"id\", \"_local_seq\": \"localSeq\", \"_rev\": \"rev\", \"_revisions\": {\"ids\": [\"ids\"], \"start\": 1}, \"_revs_info\": [{\"rev\": \"rev\", \"status\": \"available\"}], \"autoupdate\": true, \"filters\": {\"mapKey\": \"inner\"}, \"indexes\": {\"mapKey\": {\"analyzer\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"], \"default\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}, \"fields\": {\"mapKey\": {\"name\": \"classic\", \"stopwords\": [\"stopwords\"]}}}, \"index\": \"index\"}}, \"language\": \"javascript\", \"options\": {\"partitioned\": false}, \"validate_doc_update\": \"validateDocUpdate\", \"views\": {\"mapKey\": {\"map\": \"map\", \"reduce\": \"reduce\"}}}";
String getDesignDocumentPath = "/testString/_design/testString";
server.enqueue(new MockResponse()
.setHeader("Content-type", "application/json")
Expand Down Expand Up @@ -2443,6 +2443,7 @@ public void testPutDesignDocumentWOptions() throws Throwable {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("standard")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ public void testAnalyzerConfiguration() throws Throwable {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("classic")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();
assertEquals(analyzerConfigurationModel.name(), "classic");
assertEquals(analyzerConfigurationModel.stopwords(), java.util.Arrays.asList("testString"));
assertEquals(analyzerConfigurationModel.xDefault(), analyzerModel);
assertEquals(analyzerConfigurationModel.fields(), java.util.Collections.singletonMap("key1", analyzerModel));

String json = TestUtilities.serialize(analyzerConfigurationModel);

AnalyzerConfiguration analyzerConfigurationModelNew = TestUtilities.deserialize(json, AnalyzerConfiguration.class);
assertTrue(analyzerConfigurationModelNew instanceof AnalyzerConfiguration);
assertEquals(analyzerConfigurationModelNew.name(), "classic");
assertEquals(analyzerConfigurationModelNew.xDefault().toString(), analyzerModel.toString());
}

@Test(expectedExceptions = IllegalArgumentException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ public void testDesignDocument() throws Throwable {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("classic")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();
assertEquals(analyzerConfigurationModel.name(), "classic");
assertEquals(analyzerConfigurationModel.stopwords(), java.util.Arrays.asList("testString"));
assertEquals(analyzerConfigurationModel.xDefault(), analyzerModel);
assertEquals(analyzerConfigurationModel.fields(), java.util.Collections.singletonMap("key1", analyzerModel));

SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ public void testPutDesignDocumentOptions() throws Throwable {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("classic")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();
assertEquals(analyzerConfigurationModel.name(), "classic");
assertEquals(analyzerConfigurationModel.stopwords(), java.util.Arrays.asList("testString"));
assertEquals(analyzerConfigurationModel.xDefault(), analyzerModel);
assertEquals(analyzerConfigurationModel.fields(), java.util.Collections.singletonMap("key1", analyzerModel));

SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public void testSearchIndexDefinition() throws Throwable {
AnalyzerConfiguration analyzerConfigurationModel = new AnalyzerConfiguration.Builder()
.name("classic")
.stopwords(java.util.Arrays.asList("testString"))
.xDefault(analyzerModel)
.fields(java.util.Collections.singletonMap("key1", analyzerModel))
.build();
assertEquals(analyzerConfigurationModel.name(), "classic");
assertEquals(analyzerConfigurationModel.stopwords(), java.util.Arrays.asList("testString"));
assertEquals(analyzerConfigurationModel.xDefault(), analyzerModel);
assertEquals(analyzerConfigurationModel.fields(), java.util.Collections.singletonMap("key1", analyzerModel));

SearchIndexDefinition searchIndexDefinitionModel = new SearchIndexDefinition.Builder()
Expand Down