Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
basemkhirat authored Feb 27, 2017
1 parent 00f425c commit 0966576
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ $documents = $connection->search("hello")->get();
'scheme' => env('ELASTIC_SCHEME', 'http'),
]
],
'index' => env('ELASTIC_INDEX', 'my_index'),
'type' => env('ELASTIC_TYPE', 'my_type'),
'index' => env('ELASTIC_INDEX', 'my_index')
]
],

Expand Down Expand Up @@ -641,7 +640,7 @@ ES::raw()->search([
##### Insert a new document

```php
ES::id(3)->insert([
ES::type("my_type")->id(3)->insert([
"title" => "Test document",
"content" => "Sample content"
]);
Expand Down Expand Up @@ -684,7 +683,7 @@ ES::index("my_index")->type("my_type")->bulk(function ($bulk){

# you can use old bulk code style using multidimensional array of [id => data] pairs

ES::bulk([
ES::type("my_type")->bulk([

10 => [
"title" => "Test document 1",
Expand All @@ -703,7 +702,7 @@ ES::bulk([

##### Update an existing document
```php
ES::id(3)->update([
ES::type("my_type")->id(3)->update([
"title" => "Test document",
"content" => "sample content"
]);
Expand All @@ -715,11 +714,11 @@ ES::id(3)->update([

##### Incrementing field
```php
ES::id(3)->increment("views");
ES::type("my_type")->id(3)->increment("views");

# Document has _id = 3 will be incremented by 1.

ES::id(3)->increment("views", 3);
ES::type("my_type")->id(3)->increment("views", 3);

# Document has _id = 3 will be incremented by 3.

Expand All @@ -728,11 +727,11 @@ ES::id(3)->increment("views", 3);

##### Decrementing field
```php
ES::id(3)->decrement("views");
ES::type("my_type")->id(3)->decrement("views");

# Document has _id = 3 will be decremented by 1.

ES::id(3)->decrement("views", 3);
ES::type("my_type")->id(3)->decrement("views", 3);

# Document has _id = 3 will be decremented by 3.

Expand All @@ -744,29 +743,29 @@ ES::id(3)->decrement("views", 3);
```php
# increment field by script

ES::id(3)->script(
ES::type("my_type")->id(3)->script(
"ctx._source.$field += params.count",
["count" => 1]
);

# add php tag to tags array list

ES::id(3)->script(
ES::type("my_type")->id(3)->script(
"ctx._source.tags.add(params.tag)",
["tag" => "php"]
);

# delete the doc if the tags field contain mongodb, otherwise it does nothing (noop)

ES::id(3)->script(
ES::type("my_type")->id(3)->script(
"if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'none' }",
["tag" => "mongodb"]
);
```

##### Delete a document
```php
ES::id(3)->delete();
ES::type("my_type")->id(3)->delete();

# Document has _id = 3 will be deleted.

Expand Down

0 comments on commit 0966576

Please sign in to comment.