Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we use lowercase @cbelasticsearch in docs getInstance() calls #136

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
42 changes: 21 additions & 21 deletions docs/Documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Documents are the searchable, serialized objects within your indexes. As noted
The `Document` model is the primary object for creating and working with Documents. Let's say, again, we were going to create a new document in our index. We would do so, by first creating a `Document` object.

```js
var book = getInstance( "Document@cbElasticsearch" ).new(
var book = getInstance( "Document@cbelasticsearch" ).new(
index = "bookshop",
type = "_doc",
properties = {
Expand Down Expand Up @@ -60,7 +60,7 @@ To retrieve an existing document, we must first know the `_id` value. We can ei
Using the `Document` object's accessors:

```js
var existingDocument = getInstance( "Document@cbElasticsearch" )
var existingDocument = getInstance( "Document@cbelasticsearch" )
.setIndex( "bookshop" )
.setType( "_doc" )
.setId( bookId )
Expand All @@ -70,7 +70,7 @@ var existingDocument = getInstance( "Document@cbElasticsearch" )
Calling the `get()` method with explicit arguments:

```js
var existingDocument = getInstance( "Document@cbElasticsearch" )
var existingDocument = getInstance( "Document@cbelasticsearch" )
.get(
id = bookId,
index = "bookshop",
Expand All @@ -81,7 +81,7 @@ var existingDocument = getInstance( "Document@cbElasticsearch" )
Calling directly, using the same arguments, from the client:

```js
var existingDocument = getInstance( "Client@cbElasticsearch" )
var existingDocument = getInstance( "Client@cbelasticsearch" )
.get(
id = bookId,
index = "bookshop",
Expand All @@ -92,7 +92,7 @@ var existingDocument = getInstance( "Client@cbElasticsearch" )
The `get` method also accepts a struct of [query parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html#docs-get-api-query-params) to pass to the document retrieval request. For example, we only want certain items returned in the document JSON, we can pass a `_source_includes` query parameter:

```js
var minimal = getInstance( "Client@cbElasticsearch" )
var minimal = getInstance( "Client@cbelasticsearch" )
.get(
id = bookId,
index = "bookshop",
Expand All @@ -116,15 +116,15 @@ existingDocument.populate( properties = myUpdatedBookStruct ).save()
You can also pass Document objects to the `Client`'s `save()` method:

```js
getInstance( "Client@cbElasticsearch" ).save( existingDocument );
getInstance( "Client@cbelasticsearch" ).save( existingDocument );
```

#### Save Documents with an Index Refresh

If you need your document available immediately (such as during a test or pipeline), you can pass `refresh = true` to [instruct Elasticsearch to refresh the relevant index shard immediately and synchronously](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-refresh.html):

```js
getInstance( "Client@cbElasticsearch" ).save(
getInstance( "Client@cbelasticsearch" ).save(
document = existingDocument,
refresh = true
);
Expand All @@ -133,7 +133,7 @@ getInstance( "Client@cbElasticsearch" ).save(
The refresh parameter also accepts a `wait_for` option, which tells Elasticsearch to wait until the next index refresh:

```js
getInstance( "Client@cbElasticsearch" ).save(
getInstance( "Client@cbelasticsearch" ).save(
document = existingDocument,
refresh = "wait_for"
);
Expand All @@ -144,7 +144,7 @@ getInstance( "Client@cbElasticsearch" ).save(
The `patch` method of the Client allows a user to update select fields, bypassing the need for a fully retrieved document. This is similar to an `UPDATE foo SET bar = 'xyz' WHERE id = :id` query on a relational database. The method requires an index name, identifier and a struct containing the keys to be updated:

```js
getInstance( "Client@cbElasticsearch" ).patch(
getInstance( "Client@cbelasticsearch" ).patch(
"bookshop",
bookId,
{
Expand All @@ -156,7 +156,7 @@ getInstance( "Client@cbElasticsearch" ).patch(
Nested keys can also be updated using dot-notation:

```js
getInstance( "Client@cbElasticsearch" ).patch(
getInstance( "Client@cbelasticsearch" ).patch(
"bookshop",
bookId,
{
Expand Down Expand Up @@ -202,7 +202,7 @@ var ops = [
}
];

getInstance( "Client@cbElasticsearch" ).processBulkOperation( ops, { "refresh" : true } );
getInstance( "Client@cbelasticsearch" ).processBulkOperation( ops, { "refresh" : true } );
```

#### Bulk Saving of Documents
Expand All @@ -213,7 +213,7 @@ Builk inserts and updates can be peformed by passing an array of `Document` obje
var documents = [];

for( var myStruct in myArray ){
var document = getInstance( "Document@cbElasticsearch" ).new(
var document = getInstance( "Document@cbelasticsearch" ).new(
index = myIndex,
type = myType,
properties = myStruct
Expand All @@ -222,7 +222,7 @@ for( var myStruct in myArray ){
arrayAppend( documents, document );
}

getInstance( "Client@cbElasticsearch" ).saveAll( documents );
getInstance( "Client@cbelasticsearch" ).saveAll( documents );
```


Expand All @@ -233,9 +233,9 @@ For advanced updates to documents in the index, the `updateByQuery` method can p
Let's say, for example, that you need to add a new key, with a default value, to every document in your index where the key does not already exist:

```js
var searchBuilder = getInstance( "SearchBuilder@cbElasticsearch" )
var searchBuilder = getInstance( "SearchBuilder@cbelasticsearch" )
.mustNotExist( "isInPrint" );
getInstance( "Client@cbElasticsearch" )
getInstance( "Client@cbelasticsearch" )
.updateByQuery(
searchBuilder,
{
Expand All @@ -252,12 +252,12 @@ Note the variable `ctx._source` used in the script, which is a reference to the
Note that a Painless script containing newlines, tabs, or space indentation will throw a parsing error. To work around this limitation, use CBElasticsearch's `Util.formatToPainless( string script )` method to remove newlines and indentation:

```js
getInstance( "Client@cbElasticsearch" )
getInstance( "Client@cbelasticsearch" )
.updateByQuery(
searchBuilder,
{
"lang" : "painless",
"script" : getInstance( "Util@cbElasticsearch" )
"script" : getInstance( "Util@cbelasticsearch" )
.formatToPainless( getReindexScript() )
}
);
Expand All @@ -269,7 +269,7 @@ getInstance( "Client@cbElasticsearch" )
Deleting documents is similar to the process of saving. The `Document` object may be used to delete a single item.

```js
var document = getInstance( "Document@cbElasticsearch" )
var document = getInstance( "Document@cbelasticsearch" )
.get(
id = documentId,
index = "bookshop",
Expand All @@ -283,13 +283,13 @@ if( !isNull( document ) ){
Documents may also be deleted by passing a `Document` instance to the client:

```js
getInstance( "Client@cbElasticsearch" ).delete( myDocument );
getInstance( "Client@cbelasticsearch" ).delete( myDocument );
```

Finally, documents may also be deleted by query, using the `SearchBuilder` ( more below ):

```js
getInstance( "SearchBuilder@cbElasticsearch" )
getInstance( "SearchBuilder@cbelasticsearch" )
.new( index="bookshop", type="books" )
.match( "name", "Elasticsearch for Coldbox" )
.deleteAll();
Expand All @@ -305,7 +305,7 @@ The search builder also supports the addition of URL parameters, which may be us
Of note are the throttling parameters, which are useful in dealing with large documents and/or indices. By default elasticsearch processes batch operations in groups of 1000 documents. Depending on the size of your documents and the collection, it may be preferable to throttle the batch to a smaller number of documents per batch:

```js
getInstance( "SearchBuilder@cbElasticsearch" )
getInstance( "SearchBuilder@cbelasticsearch" )
.new( index="bookshop", type="books" )
.match( "name", "Elasticsearch for Coldbox" )
.param( "scroll_size", 100 )
Expand Down
2 changes: 1 addition & 1 deletion docs/Getting-Started/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ By default the following are in place, without additional configuration:
moduleSettings = {
"cbElasticsearch" = {
//The native client Wirebox DSL for the transport client
client="HyperClient@cbElasticsearch",
client="HyperClient@cbelasticsearch",
// The default hosts - an array of host connections
// - REST-based clients (e.g. JEST): round robin connections will be used
// - Socket-based clients (e.g. Transport): cluster-aware routing used
Expand Down
6 changes: 3 additions & 3 deletions docs/Getting-Started/Secondary-Cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var secondaryConfig = wirebox.getInstance( "Config@SecondaryCluster" );
// note that we need a full config structure passed in as an override to the coldbox settings
secondaryConfig.setConfigStruct( settings );

// note that we are using the native JEST client rather than Client@cbElasticsearch
// note that we are using the native JEST client rather than Client@cbelasticsearch
binder.map( "Client@SecondaryCluster" )
.to( "cbElasticsearch.models.JestClient" )
.initWith( configuration=secondaryConfig )
Expand All @@ -91,7 +91,7 @@ if( wirebox.containsInstance( "Client@SecondaryCluster" ) ){
Now you may perform a search, considering the caveat that the search must now be executed through the client:

```js
var searchBuilder = getInstance( "SearchBuilder@cbElasticsearch" ).new( "myOtherIndex" );
var searchBuilder = getInstance( "SearchBuilder@cbelasticsearch" ).new( "myOtherIndex" );
searchBuilder.term( "foo", "bar" );

var searchResult = getInstance( "Client@SecondaryCluster" ).executeSearch( searchBuilder );
Expand All @@ -100,7 +100,7 @@ var searchResult = getInstance( "Client@SecondaryCluster" ).executeSearch( searc
Document saves, retrievals, and deletions would need to be routed through the client, as well, rather than using the `save()` function:

```js
var newDocument = getInstance( "Document@cbElasticsearch" ).new( { "id" : createUUID(), "foo" : "bar" } );
var newDocument = getInstance( "Document@cbelasticsearch" ).new( { "id" : createUUID(), "foo" : "bar" } );
getInstance( "Client@SecondaryCluster" ).save( newDocument );


Expand Down
2 changes: 1 addition & 1 deletion docs/Indices/Aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ variables.client.applyAliases(
The client's `getAliases` method allows you to retrieve a map containing information on aliases in use in the connected cluster.

```js
var aliasMap = getInstance( "Client@cbElasticsearch" ).getAliases();
var aliasMap = getInstance( "Client@cbelasticsearch" ).getAliases();
```

The corresponding object will have two keys: `aliases` and `unassigned`. The former is a map of aliases with their corresponding index, the latter is an array of indexes which are unassigned to any alias.
2 changes: 1 addition & 1 deletion docs/Indices/Data-Streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Now we can create our data stream in one of two ways. We can either send data to
Create a data stream manually without data:

```js
getInstance( "Client@cbElasticsearch" ).ensureDataStream( "my-index-foo" );
getInstance( "Client@cbelasticsearch" ).ensureDataStream( "my-index-foo" );
```

This will create the data stream and backing indices for the data stream named `my-index-foo`.
Expand Down
38 changes: 19 additions & 19 deletions docs/Indices/Managing-Indices.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ By default, Elasticsearch will dynamically generate these index mapping when a d
To retrieve a list of all indices on the connected cluster, use the client `getIndices` method:

```js
var indexMap = getInstance( "Client@cbElasticsearch" ).getIndices();
var indexMap = getInstance( "Client@cbelasticsearch" ).getIndices();
```

This will return a struct of all indices ( with the names as keys ), which will provide additional information on each index, such as:
Expand All @@ -27,7 +27,7 @@ This will return a struct of all indices ( with the names as keys ), which will
The `IndexBuilder` model assists with the creation and mapping of indices. Mappings define the allowable data types within your documents and allow for better and more accurate search aggregations. Let's say we have a book model that we intend to make searchable via a `bookshop` index. Let's go ahead and create the index using the IndexBuilder:

```js
var indexBuilder = getInstance( "IndexBuilder@cbElasticsearch" ).new( "bookshop" ).save();
var indexBuilder = getInstance( "IndexBuilder@cbelasticsearch" ).new( "bookshop" ).save();
```

This will create an empty index which we can begin populating with documents.
Expand All @@ -37,7 +37,7 @@ This will create an empty index which we can begin populating with documents.
To avoid the inherent troubles with dynamic mappings, you can define an explicit mapping using the `properties` argument:

```js
getInstance( "IndexBuilder@cbElasticsearch" )
getInstance( "IndexBuilder@cbelasticsearch" )
.new(
name = "bookshop",
properties = {
Expand All @@ -64,12 +64,12 @@ While it is not *required* that you explicitly define an index mapping, it is **

## Using Client.ApplyIndex

In the previous examples, we've created the index and mapping from the IndexBuilder itself. If we wish, we could instead pass the `IndexBuilder` object to the `Client@cbElasticsearch` instance's `applyIndex( required IndexBuilder indexBuilder )` method:
In the previous examples, we've created the index and mapping from the IndexBuilder itself. If we wish, we could instead pass the `IndexBuilder` object to the `Client@cbelasticsearch` instance's `applyIndex( required IndexBuilder indexBuilder )` method:

```js
var myNewIndex = indexBuilder.new( "bookshop" )
.populate( getInstance( "BookshopIndexConfig@myApp" ).getConfig() );
getInstance( "Client@cbElasticsearch" ).applyIndex( myNewIndex );
getInstance( "Client@cbelasticsearch" ).applyIndex( myNewIndex );
```

## Configuring Index Settings
Expand Down Expand Up @@ -140,35 +140,35 @@ indexBuilder.patch(
To retreive a list of all settings for an index you may use the `getSettings` method on the client.

```js
var indexSettings = getInstance( "Client@CBElasticsearch" ).getSettings( "bookshop" )
var indexSettings = getInstance( "Client@cbelasticsearch" ).getSettings( "bookshop" )
```
## Retrieving Mappings for an Index
To retreive a list of the configured mappings for an index you may use the `getMappings` method on the client.

```js
var mappings = getInstance( "Client@CBElasticsearch" ).getMappings( "reviews" );
var mappings = getInstance( "Client@cbelasticsearch" ).getMappings( "reviews" );
```

## Triggering an index refresh

On occasion, you may need to ensure the index is updated in real time (immediately and synchronously). This can be done via the `refreshIndex()` client method:

```js
var mappings = getInstance( "Client@CBElasticsearch" ).refreshIndex( "reviews" );
var mappings = getInstance( "Client@cbelasticsearch" ).refreshIndex( "reviews" );
```

You can refresh multiple indices at once:

```js
var mappings = getInstance( "Client@CBElasticsearch" ).refreshIndex( [ "reviews", "books" ] );
var mappings = getInstance( "Client@cbelasticsearch" ).refreshIndex( [ "reviews", "books" ] );
// OR
var mappings = getInstance( "Client@CBElasticsearch" ).refreshIndex( "reviews,books" );
var mappings = getInstance( "Client@cbelasticsearch" ).refreshIndex( "reviews,books" );
```

as well as pass [supported query parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html#refresh-api-query-params) to the refresh endpoint. This can be useful when using wildcards in the index/alias names:

```js
var mappings = getInstance( "Client@CBElasticsearch" ).refreshIndex(
var mappings = getInstance( "Client@cbelasticsearch" ).refreshIndex(
[ "reviews", "book*" ],
{ "ignore_unavailable" : true }
);
Expand All @@ -179,33 +179,33 @@ var mappings = getInstance( "Client@CBElasticsearch" ).refreshIndex(
To retrieve statistics on an index, use the `getIndexStats()` method:

```js
var mappings = getInstance( "Client@CBElasticsearch" ).getIndexStats( "reviews" );
var mappings = getInstance( "Client@cbelasticsearch" ).getIndexStats( "reviews" );
```

You can retrieve particular statistics metrics:

```js
var mappings = getInstance( "Client@CBElasticsearch" )
var mappings = getInstance( "Client@cbelasticsearch" )
.getIndexStats( "reviews", [ "indexing", "search" ] );
```

Or all metrics:

```js
var mappings = getInstance( "Client@CBElasticsearch" )
var mappings = getInstance( "Client@cbelasticsearch" )
.getIndexStats( "reviews", [ "_all" ] );
```

You can even retrieve all metrics on all indices by skipping the `indexName` parameter entirely:

```js
var mappings = getInstance( "Client@CBElasticsearch" ).getIndexStats();
var mappings = getInstance( "Client@cbelasticsearch" ).getIndexStats();
```

Finally, you can pass a struct of parameters to fine-tune the statistics result:

```js
var mappings = getInstance( "Client@CBElasticsearch" )
var mappings = getInstance( "Client@cbelasticsearch" )
.getIndexStats(
"reviews",
[ "_all" ],
Expand All @@ -218,14 +218,14 @@ var mappings = getInstance( "Client@CBElasticsearch" )
Elasticsearch allows [mapping runtime fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/runtime-mapping-fields.html), which are fields calculated at search time and returned in the `"fields"` array.

```js
var script = getInstance( "Util@CBElasticsearch" )
var script = getInstance( "Util@cbelasticsearch" )
.formatToPainless("
if( doc['summary'].value.contains('love') ){ emit('😍');}
if( doc['summary'].value.contains('great') ){ emit('🚀');}
if( doc['summary'].value.contains('hate') ){ emit('😡');}
if( doc['summary'].value.contains('broke') ){ emit('💔');}
");
getInstance( "Client@CBElasticsearch" )
getInstance( "Client@cbelasticsearch" )
.patch( "reviews", {
"mappings" : {
"runtime" : {
Expand All @@ -247,7 +247,7 @@ This `summarized_emotions` field [can then be retrieved during a search](https:/
All good things must come to an end, eh? You can use `Client.deleteIndex()` to delete an existing index:

```js
getInstance( "Client@CBElasticsearch" ).deleteIndex( "reviews" )
getInstance( "Client@cbelasticsearch" ).deleteIndex( "reviews" )
```

Or you can use `IndexBuilder.delete()`:
Expand Down
Loading
Loading