-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1930 from reebhub/PHP_sessionBatch3_query
[PHP] Client API session batch 3 (querying) [Replace C# samples]
- Loading branch information
Showing
28 changed files
with
2,761 additions
and
15 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
...n.Pages/client-api/session/querying/debugging/include-explanations.php.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Include Query Explanations | ||
|
||
--- | ||
|
||
{NOTE: } | ||
|
||
* When making a query, each document in the query results is assigned a **score**. | ||
This score determines the order by which the documents come back in the results when requesting | ||
to [order by score](../../../../client-api/session/querying/sort-query-results#order-by-score). | ||
|
||
* Each document in the results includes this score under the `@index-score` property in its metadata. | ||
|
||
* Use `includeExplanations` to get the score details and see how it was calculated. | ||
|
||
* In this page: | ||
* [Include explanations in a query](../../../../client-api/session/querying/debugging/include-explanations#include-explanations-in-a-query) | ||
* [View explanations](../../../../client-api/session/querying/debugging/include-explanations#view-explanations) | ||
* [Syntax](../../../../client-api/session/querying/debugging/include-explanations#syntax) | ||
{NOTE/} | ||
|
||
--- | ||
|
||
{PANEL: Include explanations in a query} | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query explain@ClientApi\Session\Querying\Debugging\IncludeExplanations.php /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Products" | ||
where search(Name, "Syrup") or search(Name, "Lager") | ||
include explanations() | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{NOTE: } | ||
Please note that the First parameter is optional. | ||
If you intend to use the default options, just paste `null` instead of the options object. | ||
{NOTE/} | ||
|
||
{PANEL/} | ||
|
||
{PANEL: View explanations} | ||
|
||
* The detailed explanations can be viewed from the **Query view** in Studio. | ||
|
||
* Running a query with `includeExplanations` will show an additional **Explanations Tab**. | ||
|
||
![Figure 1. Explanations in the Studio](images/include-explanations-1.png "Include explanations") | ||
|
||
* Sample score details: | ||
|
||
![Figure 2. View explanations](images/include-explanations-2.png "View explanation") | ||
|
||
{PANEL/} | ||
|
||
{PANEL: Syntax} | ||
|
||
{CODE:php syntax@ClientApi\Session\Querying\Debugging\IncludeExplanations.php /} | ||
|
||
| Parameters | Data type | Description | | ||
| - | - | - | | ||
| **$options** | `?ExplanationOptions` | This object is optional.<br>If you intend to use the default options, place `null` here. | | ||
| **&$explanations** | `Explanations` | <ul><li>A callback function (action) that takes `Explanations` as an argument. It will be called by the client with the resulting `Explanations`.</li> <li>You can interact with resulting Explanations inside your callback.</li></ul> | | ||
|
||
{PANEL/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...entation.Pages/client-api/session/querying/debugging/query-timings.php.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Include Query Timings | ||
|
||
--- | ||
|
||
{NOTE: } | ||
|
||
* When making a query, | ||
you can request to get detailed stats of the time spent by RavenDB on each part of the query. | ||
E.g. duration of search, loading documents, transforming results, total duration, etc. | ||
|
||
* By default, the timings stats are Not included in the query results, to avoid the measuring overhead. | ||
|
||
* **To include the query timings** in the query results: | ||
add a call to the `timings()` method in your query code, or add `include timings()` to an RQL query. | ||
See examples below. | ||
|
||
* In this page: | ||
* [Include timings in a query](../../../../client-api/session/querying/debugging/query-timings#include-timings-in-a-query) | ||
* [View timings](../../../../client-api/session/querying/debugging/query-timings#view-timings) | ||
* [Syntax](../../../../client-api/session/querying/debugging/query-timings#syntax) | ||
|
||
{NOTE/} | ||
|
||
--- | ||
|
||
{PANEL: Include timings in a query} | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query timing_2@ClientApi\Session\Querying\Debugging\IncludeQueryTimings.php /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Products" | ||
where search(Name, "Syrup") or search(Name, "Lager") | ||
include timings() | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
{PANEL: View timings} | ||
|
||
* The detailed timings can be viewed from Studio's [Query view](../../../../studio/database/queries/query-view). | ||
|
||
* Running an RQL query with `include timings()` will show an additional **Timings Tab** | ||
with a graphical representation of the time spent in each query part. | ||
|
||
![Figure 1. Include timings graphical results](images/include-timings.png "Include timings results") | ||
|
||
{PANEL/} | ||
|
||
{PANEL: Syntax} | ||
|
||
{CODE:php syntax@ClientApi\Session\Querying\Debugging\IncludeQueryTimings.php /} | ||
|
||
| Parameter | Type | Description | | ||
|-------------|----------------|---------------| | ||
| **&$timings** | `QueryTimings` | A callback function (action) that takes `QueryTimings` as an argument. It will be called by the client with the resulting `QueryTimings`. You can interact with the resulting `QueryTimings` inside your callback. | | ||
|
||
{PANEL/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...Pages/client-api/session/querying/text-search/boost-search-results.php.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Boost Search Results | ||
|
||
--- | ||
|
||
{NOTE: } | ||
|
||
* When querying with some filtering conditions, | ||
a basic score is calculated for each document in the results by the underlying engine. | ||
|
||
* Providing a boost value to some fields allows you to prioritize the resulting documents. | ||
The boost value is integrated with the basic score, making the document rank higher. | ||
|
||
* Boosting can be achieved in the following ways: | ||
|
||
* **At query time**: | ||
Apply a boost factor to searched terms at query time - as described in this article. | ||
|
||
* **Via index definition**: | ||
Apply a boost factor in your index definition - see this [boosting](../../../../indexes/boosting) indexing article. | ||
|
||
* The automatic ordering of the results by the score is configurable. | ||
Learn more here: [automatic score-based ordering](../../../../indexes/boosting#automatic-score-based-ordering) | ||
|
||
* The calculated score details of the results can be retrieved if needed. | ||
Learn more here: [get resulting score](../../../../client-api/session/querying/sort-query-results#get-resulting-score) | ||
|
||
* In this page: | ||
|
||
* [Boost results - when making a full-text search](../../../../client-api/session/querying/text-search/boost-search-results#boost-results---when-making-a-full-text-search) | ||
* [Boost results - when querying with where clause](../../../../client-api/session/querying/text-search/boost-search-results#boost-results---when-querying-with-where-clause) | ||
|
||
{NOTE/} | ||
|
||
--- | ||
|
||
{PANEL: Boost results - when making a full-text search} | ||
|
||
To apply boosting while running a full-text search, use the | ||
`boost()` method to prioritize the preceding `search()` results. | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query boost_1@ClientApi\Session\Querying\TextSearch\BoostResults.php /} | ||
{CODE-TAB:csharp:documentQuery boost_3@ClientApi\Session\Querying\TextSearch\BoostResults.cs /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Employees" where | ||
search(Notes, "English") or boost(search(Notes, "Italian"), 10) | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
{PANEL: Boost results - when querying with where clause} | ||
|
||
`boost()` can be used to give different priorities to the results | ||
returned by different `where` clauses. | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query boost_4@ClientApi\Session\Querying\TextSearch\BoostResults.php /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Companies" where | ||
boost(startsWith(Name, "O"), 10) or | ||
boost(startsWith(Name, "P"), 50) or | ||
boost(endsWith(Name, "OP"), 90) | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
## Related Articles | ||
|
||
### Session | ||
|
||
- [Query overview](../../../../client-api/session/querying/how-to-query) | ||
- [Full-text search](../../../../client-api/session/querying/text-search/full-text-search) | ||
|
||
### Indexes | ||
|
||
- [Full-text search with index](../../../../indexes/querying/searching) |
74 changes: 74 additions & 0 deletions
74
...tion.Pages/client-api/session/querying/text-search/ends-with-query.php.markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# where_ends_with Query | ||
|
||
--- | ||
|
||
{NOTE: } | ||
|
||
* You can query for documents having a field that ends with some specified string. | ||
|
||
* Unless explicitly specified, the string comparisons are case-insensitive by default. | ||
|
||
* **Note**: | ||
This postfix search causes the server to perform a full index scan. | ||
Instead, consider using a static index that indexes the field in reverse order | ||
and then query with a [prefix search](../../../../client-api/session/querying/text-search/starts-with-query), which is much faster. | ||
|
||
* In this page: | ||
* [where_ends_with](../../../../client-api/session/querying/text-search/ends-with-query#where_ends_with) | ||
* [where_ends_with (case-sensitive)](../../../../client-api/session/querying/text-search/ends-with-query#where_ends_with-(case-sensitive)) | ||
* [Negate where_ends_with](../../../../client-api/session/querying/text-search/ends-with-query#negate-where_ends_with) | ||
|
||
{NOTE/} | ||
|
||
--- | ||
|
||
{PANEL: where_ends_with} | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query endsWith_1@ClientApi\Session\Querying\TextSearch\EndsWith.php /} | ||
{CODE-TAB:csharp:documentQuery endsWith_3@ClientApi\Session\Querying\TextSearch\EndsWith.cs /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Products" | ||
where endsWith(Name, "Lager") | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
{PANEL: where_ends_with (case-sensitive)} | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query endsWith_4@ClientApi\Session\Querying\TextSearch\EndsWith.php /} | ||
{CODE-TAB:csharp:documentQuery endsWith_6@ClientApi\Session\Querying\TextSearch\EndsWith.cs /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Products" | ||
where exact(endsWith(Name, "Lager")) | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
{PANEL: Negate where_ends_with} | ||
|
||
{CODE-TABS} | ||
{CODE-TAB:php:query endsWith_7@ClientApi\Session\Querying\TextSearch\EndsWith.php /} | ||
{CODE-TAB:csharp:documentQuery endsWith_9@ClientApi\Session\Querying\TextSearch\EndsWith.cs /} | ||
{CODE-TAB-BLOCK:sql:RQL} | ||
from "Products" | ||
where (true and not endsWith(Name, "Lager")) | ||
{CODE-TAB-BLOCK/} | ||
{CODE-TABS/} | ||
|
||
{PANEL/} | ||
|
||
## Related Articles | ||
|
||
### Session | ||
|
||
- [Query overview](../../../../client-api/session/querying/how-to-query) | ||
- [Starts-With query](../../../../client-api/session/querying/text-search/starts-with-query) | ||
- [Full-text search](../../../../client-api/session/querying/text-search/full-text-search) | ||
|
||
### Indexes | ||
|
||
- [map indexes](../../../../indexes/map-indexes) |
Oops, something went wrong.