From 5ae231c99b39ec56f7177268908c69a519df3010 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mantas=20Urnie=C5=BEa?= <mantas.urnieza@nfq.lt>
Date: Tue, 8 Dec 2015 12:49:19 +0200
Subject: [PATCH] Documentation for custom parameters.

---
 docs/HowTo/CustomParameters.md | 73 ++++++++++++++++++++++++++++++++++
 docs/index.md                  |  1 +
 2 files changed, 74 insertions(+)
 create mode 100644 docs/HowTo/CustomParameters.md

diff --git a/docs/HowTo/CustomParameters.md b/docs/HowTo/CustomParameters.md
new file mode 100644
index 0000000..1fed5b3
--- /dev/null
+++ b/docs/HowTo/CustomParameters.md
@@ -0,0 +1,73 @@
+# How to set custom parameters to your search
+
+Elasticsearch supports number of custom parameters which can be added to your query. Detailed explanation of each parameter can be found at [official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#_parameters_5)
+
+## Setting `timeout` parameter
+
+This option allows user to specify timeout for query execution in ["Time units"](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units).
+
+Following code
+
+```php
+$search = new Search();
+$search->setTimeout('5s');
+```
+
+would generate the query like this:
+```json
+{
+  "timeout": "5s"
+}
+```
+
+## Setting `from` and `size` parameters
+
+These parameters are usually used for pagination.
+
+Following code
+
+```php
+$search = new Search();
+$search->setSize(25);
+$search->setFrom(50);
+```
+
+would generate the query like this:
+```json
+{
+  "size": 25,
+  "from": 50
+}
+```
+
+## Setting `terminate_after` parameter
+
+This parameter can limit how many documents can be fetched from shard before query execution is terminated.
+
+Following code
+
+```php
+$search = new Search();
+$search->setTerminateAfter(1000);
+```
+
+would generate the query like this:
+```json
+{
+  "terminate_after": 1000
+}
+```
+
+## Setting `search_type` and `request_cache` parameters
+
+These parameters are different from previous ones because they have to be passed not in query's body but as query string parameters.
+
+Following code
+
+```php
+$search = new Search();
+$search->setSearchType('dfs_query_then_fetch');
+$search->setRequestCache(true);
+```
+
+would generate query string with `?search_type=dfs_query_then_fetch&request_cache=true`.
\ No newline at end of file
diff --git a/docs/index.md b/docs/index.md
index 3936368..937fd46 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -11,6 +11,7 @@ Everything starts from the `Search` object. We recommend first to take a look at
 
 ### How to
 - [How to Search](HowTo/HowToSearch.md)
+- [How to set custom parameters to Search](HowTo/CustomParameters.md)
 - more coming soon..
 
 [1]: https://github.com/elastic/elasticsearch-php
-- 
GitLab