diff --git a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown index 286daa1fd4..57d39b3f98 100644 --- a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown +++ b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown @@ -39,8 +39,8 @@ Loading entities with include can be executed __lazily__. {CODE-TABS} -{CODE-TAB:csharp:Lazy-load-with-include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} -{CODE-TAB:csharp:The-document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:Lazy_load_with_include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:The_document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} {CODE-TABS/} {NOTE/} @@ -70,7 +70,7 @@ {NOTE: } __Run query__ -* A Query can be executing a __lazily__. +* A Query can be executed __lazily__. Learn more about running queries lazily in [lazy queries](../../../client-api/session/querying/how-to-perform-queries-lazily). {CODE lazy_Query@ClientApi\Session\HowTo\Lazy.cs /} diff --git a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.dotnet.markdown b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.dotnet.markdown index 2e07288bfa..860cfac5f0 100644 --- a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.dotnet.markdown +++ b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Stream Query Results +# Stream Query Results --- diff --git a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.java.markdown b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.java.markdown index 53eccbcd73..cc85494ea9 100644 --- a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.java.markdown +++ b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.java.markdown @@ -1,4 +1,4 @@ -# How to Stream Query Results +# Stream Query Results Query results can be streamed using the `stream` method from the `advanced` session operations. The query can be issued using either a static index, or it can be a dynamic one where it will be handled by an auto index. diff --git a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.js.markdown b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.js.markdown index 323ea85261..3049c32436 100644 --- a/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.js.markdown +++ b/Documentation/5.1/Raven.Documentation.Pages/client-api/session/querying/how-to-stream-query-results.js.markdown @@ -1,4 +1,4 @@ -# How to Stream Query Results +# Stream Query Results --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/.docs.json b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/.docs.json index e86101a892..eda0d8b7c7 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/.docs.json +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/.docs.json @@ -25,7 +25,7 @@ }, { "Path": "perform-operations-lazily.markdown", - "Name": "...perform operations lazily", + "Name": "...perform requests lazily", "DiscussionId": "7a54c2fc-67ee-40e6-94b5-1266e990cf57", "Mappings": [ { diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown index 38b1537c4d..a4243cd39e 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown @@ -1,27 +1,42 @@ -# How to Perform Operations Lazily - +# Perform requests lazily --- {NOTE: } -* **Defining a lazy operation** allows deferring the execution of the operation until it is needed. +* __Lazy request__: + + * You can define a lazy request within a session (e.g. a lazy-query or a lazy-load request) + and defer its execution until actually needed. + + * The lazy request definition is stored in the session and a `Lazy` instance is returned. + The request will be sent to the server and executed only when you access the value of this instance. + +* __Multiple lazy requests__: + + * Multiple lazy requests can be defined within the same session. -* Multiple pending lazy operations can be executed together, see below. + * When triggering the deferred execution (whether implicitly or explicitly), + ALL pending lazy requests held up by the session will be sent to the server in a single call. + This can help reduce the number of remote calls made to the server over the network. * In this page: - * [Operations that can be executed lazily](../../../client-api/session/how-to/perform-operations-lazily#operations-that-can-be-executed-lazily) - * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) - * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) - * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) - * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) - * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) - * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) - * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) - * [Execute all pending lazy operations](../../../client-api/session/how-to/perform-operations-lazily#execute-all-pending-lazy-operations) + * [Requests that can be executed lazily:](../../../client-api/session/how-to/perform-operations-lazily#requests-that-can-be-executed-lazily) + * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) + * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) + * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) + * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) + * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) + * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) + * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) + * [Multiple lazy requests](../../../client-api/session/how-to/perform-operations-lazily#multiple-lazy-requests) + * [Execute all requests - implicitly](../../../client-api/session/how-to/perform-operations-lazily#implicit) + * [Execute all requests - explicitly](../../../client-api/session/how-to/perform-operations-lazily#explicit) {NOTE/} -{PANEL: Operations that can be executed lazily} +--- + +{PANEL: Requests that can be executed lazily} {NOTE: } __Load entities__ @@ -39,8 +54,8 @@ Loading entities with include can be executed __lazily__. {CODE-TABS} -{CODE-TAB:csharp:Lazy-load-with-include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} -{CODE-TAB:csharp:The-document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:Lazy_load_with_include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:The_document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} {CODE-TABS/} {NOTE/} @@ -70,8 +85,8 @@ {NOTE: } __Run query__ -* A Query can be executing a __lazily__. - Learn more about running queries lazily in [lazy queries](../../../client-api/session/querying/how-to-perform-queries-lazily). +* A Query can be executed __lazily__. + Find more lazy queries examples in [perform a lazy query](../../../client-api/session/querying/how-to-perform-queries-lazily). {CODE lazy_Query@ClientApi\Session\HowTo\Lazy.cs /} {NOTE/} @@ -94,11 +109,21 @@ {PANEL/} -{PANEL: Execute all pending lazy operations} +{PANEL: Multiple lazy requests } + +{NOTE: } + __Execute all requests - implicitly__ + +{CODE lazy_ExecuteAll_Implicit@ClientApi\Session\HowTo\Lazy.cs /} -* Use `ExecuteAllPendingLazyOperations` to execute **all** pending lazy operations at once. +{NOTE/} -{CODE lazy_ExecuteAllPendingLazyOperations@ClientApi\Session\HowTo\Lazy.cs /} +{NOTE: } + __Execute all requests - explicitly__ + +{CODE lazy_ExecuteAll_Explicit@ClientApi\Session\HowTo\Lazy.cs /} + +{NOTE/} {PANEL/} diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown index 43231a2e86..89eef4eec8 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown @@ -1,26 +1,41 @@ -# How to Perform Operations Lazily - +# Perform requests lazily --- {NOTE: } -* **Defining a lazy operation** allows deferring the execution of the operation until it is needed. +* __Lazy request__: + + * You can define a lazy request within a session (e.g. a lazy-query or a lazy-load request) + and defer its execution until actually needed. + + * The lazy request definition is stored in the session and a `Lazy` instance is returned. + The request will be sent to the server and executed only when you access the value of this instance. + +* __Multiple lazy requests__: -* Multiple pending lazy operations can be executed together, see below. + * Multiple lazy requests can be defined within the same session. + + * When triggering the deferred execution (whether implicitly or explicitly), + ALL pending lazy requests held up by the session will be sent to the server in a single call. + This can help reduce the number of remote calls made to the server over the network. * In this page: - * [Operations that can be executed lazily](../../../client-api/session/how-to/perform-operations-lazily#operations-that-can-be-executed-lazily) - * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) - * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) - * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) - * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) - * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) - * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) - * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) - * [Execute all pending lazy operations](../../../client-api/session/how-to/perform-operations-lazily#execute-all-pending-lazy-operations) + * [Requests that can be executed lazily:](../../../client-api/session/how-to/perform-operations-lazily#requests-that-can-be-executed-lazily) + * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) + * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) + * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) + * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) + * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) + * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) + * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) + * [Multiple lazy requests](../../../client-api/session/how-to/perform-operations-lazily#multiple-lazy-requests) + * [Execute all requests - implicitly](../../../client-api/session/how-to/perform-operations-lazily#implicit) + * [Execute all requests - explicitly](../../../client-api/session/how-to/perform-operations-lazily#explicit) {NOTE/} +--- + {PANEL: Operations that can be executed lazily} {NOTE: } @@ -39,8 +54,8 @@ Loading entities with include can be executed __lazily__. {CODE-TABS} -{CODE-TAB:nodejs:Lazy-load-with-include lazy_loadWithInclude@ClientApi\Session\HowTo\lazy.js /} -{CODE-TAB:nodejs:Sample-document lazy_productClass@ClientApi\Session\HowTo\lazy.js /} +{CODE-TAB:nodejs:Lazy_load_with_include lazy_loadWithInclude@ClientApi\Session\HowTo\lazy.js /} +{CODE-TAB:nodejs:The_document lazy_productClass@ClientApi\Session\HowTo\lazy.js /} {CODE-TABS/} {NOTE/} @@ -70,7 +85,7 @@ {NOTE: } __Run query__ -* A Query can be executing a __lazily__. +* A Query can be executed __lazily__. Learn more about running queries lazily in [lazy queries](../../../client-api/session/querying/how-to-perform-queries-lazily). {CODE:nodejs lazy_query@ClientApi\Session\HowTo\lazy.js /} @@ -94,11 +109,21 @@ {PANEL/} -{PANEL: Execute all pending lazy operations} +{PANEL: Multiple lazy requests } -* Use `executeAllPendingLazyOperations` to execute **all** pending lazy operations at once. +{NOTE: } + __Execute all requests - implicitly__ -{CODE:nodejs lazy_executeAllPendingLazyOperations@ClientApi\Session\HowTo\lazy.js /} +{CODE:nodejs lazy_ExecuteAll_Implicit@ClientApi\Session\HowTo\lazy.js /} + +{NOTE/} + +{NOTE: } + __Execute all requests - explicitly__ + +{CODE:nodejs lazy_ExecuteAll_Explicit@ClientApi\Session\HowTo\lazy.js /} + +{NOTE/} {PANEL/} diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown index 06fd19e48d..8c78292901 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown @@ -3,17 +3,19 @@ {NOTE: } -There are several methods with many overloads that allow users to download documents -from the database and convert them to entities. This article will cover the following -methods: - -- [Load](../../client-api/session/loading-entities#load) -- [Load with Includes](../../client-api/session/loading-entities#load-with-includes) -- [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) -- [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) -- [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) -- [Stream](../../client-api/session/loading-entities#stream) -- [IsLoaded](../../client-api/session/loading-entities#isloaded) +* There are several methods that allow users to load documents from the database and convert them to entities. + +* This article covers the following methods: + + - [Load](../../client-api/session/loading-entities#load) + - [Load with Includes](../../client-api/session/loading-entities#load-with-includes) + - [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) + - [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) + - [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) + - [Stream](../../client-api/session/loading-entities#stream) + - [IsLoaded](../../client-api/session/loading-entities#isloaded) + +* For loading entities lazily see [perform requests lazily](../../client-api/session/how-to/perform-operations-lazily). {NOTE/} diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown index f1adf1170b..c0bd8b9ae0 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown @@ -1,14 +1,25 @@ # Session: Loading Entities +--- -There are various methods with many overloads that allow users to download documents from a database and convert them to entities. This article will cover the following methods: +{NOTE: } -- [Load](../../client-api/session/loading-entities#load) -- [Load with Includes](../../client-api/session/loading-entities#load-with-includes) -- [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) -- [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) -- [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) -- [IsLoaded](../../client-api/session/loading-entities#isloaded) -- [Stream](../../client-api/session/loading-entities#stream) +* There are several methods that allow users to load documents from the database and convert them to entities. + +* This article covers the following methods: + + - [Load](../../client-api/session/loading-entities#load) + - [Load with Includes](../../client-api/session/loading-entities#load-with-includes) + - [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) + - [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) + - [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) + - [IsLoaded](../../client-api/session/loading-entities#isloaded) + - [Stream](../../client-api/session/loading-entities#stream) + +* For loading entities lazily see [perform requests lazily](../../client-api/session/how-to/perform-operations-lazily). + +{NOTE/} + +--- {PANEL:Load} diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/.docs.json b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/.docs.json index 6a77aac946..3a802ef4cb 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/.docs.json +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/.docs.json @@ -28,7 +28,7 @@ }, { "Path": "how-to-stream-query-results.markdown", - "Name": "How to Stream Query Results", + "Name": "Stream Query Results", "DiscussionId": "c96a370e-8d0d-4e8f-93b3-03a8105e8b0e", "Mappings": [ { @@ -39,7 +39,7 @@ }, { "Path": "how-to-customize-query.markdown", - "Name": "How to Customize Query", + "Name": "Customize Query", "DiscussionId": "73dfb483-1fca-4fca-a1a4-15c7366b4775", "Mappings": [] }, @@ -77,7 +77,7 @@ }, { "Path": "how-to-make-a-spatial-query.markdown", - "Name": "How to Make a Spatial Query", + "Name": "Make a Spatial Query", "DiscussionId": "b62de172-77e9-4241-a525-9ba6cc027860", "Mappings": [ { @@ -98,13 +98,13 @@ }, { "Path": "how-to-filter-by-field.markdown", - "Name": "How to Filter by Field Presence", + "Name": "Filter by Field Presence", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, { "Path": "how-to-filter-by-non-existing-field.markdown", - "Name": "How to Filter by Non-Existing Field", + "Name": "Filter by Non-Existing Field", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, @@ -121,7 +121,7 @@ }, { "Path": "how-to-perform-queries-lazily.markdown", - "Name": "How to Perform Queries Lazily", + "Name": "Perform a Lazy Query", "DiscussionId": "a359f844-7193-4228-98e0-81a07e561a8b", "Mappings": [ { diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json index d8bb75f036..a5fb6200a7 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json @@ -1,13 +1,13 @@ [ { "Path": "include-explanations.markdown", - "Name": "How to Include Query Explanations", + "Name": "Include Query Explanations", "DiscussionId": "2d056281-2f65-4180-a3e1-a6348ec2d230", "Mappings": [] }, { "Path": "query-timings.markdown", - "Name": "How to Include Query Timings", + "Name": "Include Query Timings", "DiscussionId": "873da629-f825-4378-bac9-87153227a41b", "Mappings": [] } diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.dotnet.markdown index e29cebee0d..5bfb8fb0c8 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Include Query Explanations +# Include Query Explanations --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.java.markdown index 78adf19b51..60318af676 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.java.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.java.markdown @@ -1,4 +1,4 @@ -# How to include Query Explanations +# Include Query Explanations `includeExplanations` allows to investigate details related to score assigned for each query result. diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.js.markdown index 9f6553a845..5060da4738 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/include-explanations.js.markdown @@ -1,4 +1,4 @@ -# How to Include Query Explanations +# Include Query Explanations --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown index faf8478d6f..02a1e6b981 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown index bba65f189b..e67e994b1a 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings By default, detailed timings (duration of Lucene search, loading documents, transforming results) in queries are turned off, this is due to small overhead that calculation of such timings produces. diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown index bb8f132fbe..fc66c21a19 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.dotnet.markdown index 83255689e3..c2c12bc926 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Customize a Query +# Customize Query --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.java.markdown index 84cf9322c0..b7a0edc1d5 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.java.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.java.markdown @@ -1,4 +1,5 @@ -# How to Customize a Query +# Customize Query + --- {NOTE: } diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.js.markdown index 2d1687a8f4..884dc7e417 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-customize-query.js.markdown @@ -1,4 +1,4 @@ -# How to Customize a Query +# Customize Query --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.dotnet.markdown index 9b57a09754..2bc6731126 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Filter by Field Presence +# Filter by Field Presence --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.java.markdown index fef0aa198a..7bb8cb75a0 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.java.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.java.markdown @@ -1,4 +1,4 @@ -# How to Filter by Field Presence +# Filter by Field Presence --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.js.markdown index 3b34eda220..0951cc24ee 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-field.js.markdown @@ -1,4 +1,4 @@ -# How to Filter by Field Presence +# Filter by Field Presence --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.dotnet.markdown index 30bb3e0975..a5136accc9 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Filter by Non-Existing Field +# Filter by Non-Existing Field --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.js.markdown index ca217997e4..20afb8050c 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-filter-by-non-existing-field.js.markdown @@ -1,4 +1,4 @@ -# How to Filter by Non-Existing Field +# Filter by Non-Existing Field --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.dotnet.markdown index 7bc9be332f..d3c8dda624 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.dotnet.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Make a Spatial Query +# Make a Spatial Query --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.java.markdown index 01203be755..a42ff03967 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.java.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.java.markdown @@ -1,4 +1,4 @@ -# How to Make a Spatial Query +# Make a Spatial Query Spatial indexes can be queried using the `spatial` method which contains a full spectrum of spatial methods. The following article will cover these methods: diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.js.markdown index 58ebd31daa..8a63067002 100644 --- a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.js.markdown +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-make-a-spatial-query.js.markdown @@ -1,4 +1,4 @@ -# How to Make a Spatial Query +# Make a Spatial Query --- diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.dotnet.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.dotnet.markdown new file mode 100644 index 0000000000..315d092ea2 --- /dev/null +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.dotnet.markdown @@ -0,0 +1,95 @@ +# Perform a Lazy Query + +--- + +{NOTE: } + +* Query execution can be deferred. + You can __define a query as lazy__ and execute it later when query results are actually needed. + +* This article contains lazy queries examples. + __Prior to this article__, please refer to [perform requests lazily](../../../client-api/session/how-to/perform-operations-lazily) for general knowledge about + RavenDB's lazy behavior, and other request types that can be executed lazily within a session. + +* In this page: + * [Lazy query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-query) + * [Lazy count query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-count-query) + * [Lazy suggestions query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-suggestions-query) + * [Lazy facets query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-facets-query) + * [Syntax](../../../client-api/session/querying/how-to-perform-queries-lazily#syntax) + +{NOTE/} + +--- + +{PANEL: Lazy query} + +{CODE-TABS} +{CODE-TAB:csharp:Lazy_query lazy_1@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_query_async lazy_2@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_documentQuery lazy_3@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TABS/} + +* Learn more about queries in this [query overview](../../../client-api/session/querying/how-to-query). + +{PANEL/} + +{PANEL: Lazy count query} + +{CODE-TABS} +{CODE-TAB:csharp:Lazy_query lazy_4@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_query_async lazy_5@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_documentQuery lazy_6@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TABS/} + +{PANEL/} + +{PANEL: Lazy suggestions query} + +{CODE-TABS} +{CODE-TAB:csharp:Lazy_query lazy_7@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_query_async lazy_8@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_documentQuery lazy_9@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TABS/} + +* Learn more about suggestions in [query for suggestions](../../../client-api/session/querying/how-to-work-with-suggestions). + +{PANEL/} + +{PANEL: Lazy facets query} + +{CODE-TABS} +{CODE-TAB:csharp:Lazy_query lazy_10@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_query_async lazy_11@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Lazy_documentQuery lazy_12@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Facets_definition the_facets@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TAB:csharp:Index_definition the_index@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE-TABS/} + +* Learn more about facets in [perform faceted search](../../../client-api/session/querying/how-to-perform-a-faceted-search). + +{PANEL/} + +{PANEL: Syntax} + +{CODE syntax_1@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE syntax_2@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE syntax_3@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} +{CODE syntax_4@ClientApi\Session\Querying\HowToPerformQueriesLazily.cs /} + +| Parameters | Type | Description | +|------------|-----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| +| __onEval__ | `Action>`
`Action>`
`Action>` | An action that will be performed on the query results
when the query is executed. | + +| Return Value | | +|----------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------| +| `Lazy>`
`Lazy`
`Lazy>`
`Lazy>` | A lazy instance that will evaluate the query only when needed. | + +{PANEL/} + +## Related Articles + +### Session + +- [Query overview](../../../client-api/session/querying/how-to-query) +- [Perform requests lazily](../../../client-api/session/how-to/perform-operations-lazily) diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.java.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.java.markdown new file mode 100644 index 0000000000..8ebb454aad --- /dev/null +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.java.markdown @@ -0,0 +1,70 @@ +# Perform a Lazy Query + +In some situations, query execution must be delayed. To cover such a scenario, `lazily` and many other query extensions have been introduced. + +{PANEL:Lazily} + +{CODE:java lazy_1@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +| Parameters | | | +| ------------- | ------------- | ----- | +| **onEval** | Consumer | An action that will be performed on the query results. | + +| Return Value | | +| ------------- | ----- | +| Lazy | Lazy query initializer returning query results. | + +### Example + +{CODE:java lazy_2@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +{PANEL/} + +{PANEL:Counts} + +{CODE:java lazy_4@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +| Return Value | | +| ------------- | ----- | +| Lazy | Lazy query initializer returning a count of matched documents. | + +### Example + +{CODE:java lazy_5@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +{PANEL/} + +{PANEL:Suggestions} + +{CODE:java lazy_6@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +| Return Value | | +| ------------- | ----- | +| Lazy> | Lazy query initializer containing a map with suggestions for matching executed query | + +### Example + +{CODE:java lazy_7@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +{PANEL/} + +{PANEL:Facets} + +{CODE:java lazy_8@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +| Return Value | | +| ------------- | ----- | +| Lazy> | Lazy query initializer containing a map with facet results matching executed query | + +### Example + +{CODE:java lazy_9@ClientApi\Session\Querying\HowToPerformQueriesLazily.java /} + +{PANEL/} + +## Related Articles + +### Session + +- [How to Query](../../../client-api/session/querying/how-to-query) +- [How to Perform Operations Lazily](../../../client-api/session/how-to/perform-operations-lazily) diff --git a/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.js.markdown b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.js.markdown new file mode 100644 index 0000000000..96df2f6d0d --- /dev/null +++ b/Documentation/5.2/Raven.Documentation.Pages/client-api/session/querying/how-to-perform-queries-lazily.js.markdown @@ -0,0 +1,77 @@ +# Perform a Lazy Query + +--- + +{NOTE: } + +* Query execution can be deferred. + You can __define a query as lazy__ and execute it later when query results are actually needed. + +* This article contains lazy queries examples. + __Prior to this article__, please refer to [perform requests lazily](../../../client-api/session/how-to/perform-operations-lazily) for general knowledge about + RavenDB's lazy behavior, and other request types that can be executed lazily within a session. + +* In this page: + * [Lazy query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-query) + * [Lazy count query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-count-query) + * [Lazy suggestions query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-suggestions-query) + * [Lazy facets query](../../../client-api/session/querying/how-to-perform-queries-lazily#lazy-facets-query) + * [Syntax](../../../client-api/session/querying/how-to-perform-queries-lazily#syntax) + +{NOTE/} + +--- + +{PANEL: Lazy query} + +{CODE:nodejs lazy_1@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} + +* Learn more about queries in this [query overview](../../../client-api/session/querying/how-to-query). + +{PANEL/} + +{PANEL: Lazy count query} + +{CODE:nodejs lazy_2@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} + +{PANEL/} + +{PANEL: Lazy suggestions query} + +{CODE:nodejs lazy_3@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} + +* Learn more about suggestions in [query for suggestions](../../../client-api/session/querying/how-to-work-with-suggestions). + +{PANEL/} + +{PANEL: Lazy facets query} + +{CODE-TABS} +{CODE-TAB:nodejs:Lazy_query lazy_4@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} +{CODE-TAB:nodejs:Index_definition the_index@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} +{CODE-TABS/} + +* Learn more about facets in [perform faceted search](../../../client-api/session/querying/how-to-perform-a-faceted-search). + +{PANEL/} + +{PANEL: Syntax} + +{CODE:nodejs syntax@ClientApi\Session\Querying\howToPerformQueriesLazily.js /} + +| Parameters | Type | Description | +|------------|----------------------|--------------------------------------------------------------------------------------| +| __onEval__ | `(object[]) => void` | An action that will be performed on the query results
when the query is executed. | + +| Return Value | | +|--------------|------------------------------------------------------------------| +| __object__ | A `Lazy` instance that will evaluate the query only when needed. | + +{PANEL/} + +## Related Articles + +### Session + +- [Query overview](../../../client-api/session/querying/how-to-query) +- [Perform requests lazily](../../../client-api/session/how-to/perform-operations-lazily) diff --git a/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs index 2e1dd6ddec..d892d0ab61 100644 --- a/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs +++ b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs @@ -116,7 +116,7 @@ public Lazy() using (var session = store.OpenSession()) { #region lazy_Revisions - var lazyRevisions = session + Lazy> lazyRevisions = session // Add a call to Lazily .Advanced.Revisions.Lazily // Revisions will Not be fetched here, no server call is made @@ -140,7 +140,7 @@ public Lazy() session.SaveChanges(); // Get the compare-exchange value lazily: - var lazyCmpXchg = session + Lazy> lazyCmpXchg = session // Add a call to Lazily .Advanced.ClusterTransaction.Lazily // Compare-exchange values will Not be fetched here, no server call is made @@ -156,19 +156,53 @@ public Lazy() using (var session = store.OpenSession()) { - #region lazy_ExecuteAllPendingLazyOperations + #region lazy_ExecuteAll_Implicit // Define multiple lazy requests Lazy lazyUser1 = session.Advanced.Lazily.Load("users/1-A"); Lazy lazyUser2 = session.Advanced.Lazily.Load("users/2-A"); - Lazy> lazyEmployees = session.Query().Lazily(); + + Lazy> lazyEmployees = session.Query() + .Lazily(); + Lazy> lazyProducts = session.Query() + .Search(x => x.Name, "Ch*") + .Lazily(); + + // Accessing the value of ANY of the lazy instances will trigger + // the execution of ALL pending lazy requests held up by the session + // This is done in a SINGLE server call + User user1 = lazyUser1.Value; + + // ALL the other values are now also available + // No additional server calls are made when accessing these values + User user2 = lazyUser2.Value; + IEnumerable employees = lazyEmployees.Value; + IEnumerable products = lazyProducts.Value; + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_ExecuteAll_Explicit + // Define multiple lazy requests + Lazy lazyUser1 = session.Advanced.Lazily.Load("users/1-A"); + Lazy lazyUser2 = session.Advanced.Lazily.Load("users/2-A"); + + Lazy> lazyEmployees = session.Query() + .Lazily(); + Lazy> lazyProducts = session.Query() + .Search(x => x.Name, "Ch*") + .Lazily(); - // Execute all pending lazy operations + // Explicitly call 'ExecuteAllPendingLazyOperations' + // ALL pending lazy requests held up by the session will be executed in a SINGLE server call session.Advanced.Eagerly.ExecuteAllPendingLazyOperations(); - // All values are now available + // ALL values are now available + // No additional server calls are made when accessing the values User user1 = lazyUser1.Value; User user2 = lazyUser2.Value; IEnumerable employees = lazyEmployees.Value; + IEnumerable products = lazyProducts.Value; #endregion } } diff --git a/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/Querying/HowToPerformQueriesLazily.cs b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/Querying/HowToPerformQueriesLazily.cs new file mode 100644 index 0000000000..fc14f681ca --- /dev/null +++ b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/Querying/HowToPerformQueriesLazily.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Raven.Client.Documents; +using Raven.Client.Documents.Indexes; +using Raven.Client.Documents.Queries.Facets; +using Raven.Client.Documents.Queries.Suggestions; +using Raven.Documentation.Samples.Orders; + +namespace Raven.Documentation.Samples.ClientApi.Session.Querying +{ + public class HowToPerformQueriesLazily + { + public async Task LazyQueries() + { + using (var store = new DocumentStore()) + { + using (var session = store.OpenSession()) + { + #region lazy_1 + // Define a lazy query + Lazy> lazyEmployees = session + .Query() + .Where(x => x.FirstName == "Robert") + // Add a call to 'Lazily' + .Lazily(); + + IEnumerable employees = lazyEmployees.Value; // Query is executed here + #endregion + } + + using (var asyncSession = store.OpenAsyncSession()) + { + #region lazy_2 + // Define a lazy query + Lazy>> lazyEmployees = asyncSession + .Query() + .Where(x => x.FirstName == "Robert") + // Add a call to 'LazilyAsync' + .LazilyAsync(); + + IEnumerable employees = await lazyEmployees.Value; // Query is executed here + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_3 + // Define a lazy DocumentQuery + Lazy> lazyEmployees = session.Advanced + .DocumentQuery() + .WhereEquals(x => x.FirstName, "Robert") + // Add a call to 'Lazily' + .Lazily(); + + IEnumerable employees = lazyEmployees.Value; // DocumentQuery is executed here + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_4 + // Define a lazy count query + Lazy lazyCount = session + .Query() + .Where(x => x.FirstName == "Robert") + // Add a call to 'CountLazily' + .CountLazily(); + + int count = lazyCount.Value; // Query is executed here + #endregion + } + + using (var asyncSession = store.OpenAsyncSession()) + { + #region lazy_5 + // Define a lazy count query + Lazy> lazyCount = asyncSession + .Query() + .Where(x => x.FirstName == "Robert") + // Add a call to 'CountLazilyAsync' + .CountLazilyAsync(); + + int count = await lazyCount.Value; // Query is executed here + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_6 + // Define a lazy DocumentQuery + Lazy lazyCount = session.Advanced + .DocumentQuery() + .WhereEquals(x => x.FirstName, "Robert") + // Add a call to 'CountLazily' + .CountLazily(); + + int count = lazyCount.Value; // DocumentQuery is executed here + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_7 + // Define a lazy suggestion query + Lazy> lazySuggestions = session + .Query() + .SuggestUsing(builder => builder.ByField(x => x.Name, "chaig")) + // Add a call to 'ExecuteLazy' + .ExecuteLazy(); + + Dictionary suggest = lazySuggestions.Value; // Query is executed here + List suggestions = suggest["Name"].Suggestions; + #endregion + } + + using (var asyncSession = store.OpenAsyncSession()) + { + #region lazy_8 + // Define a lazy suggestion query + Lazy>> lazySuggestions = asyncSession + .Query() + .SuggestUsing(builder => builder.ByField("Name", "chaig")) + // Add a call to 'ExecuteLazyAsync' + .ExecuteLazyAsync(); + + Dictionary suggest = await lazySuggestions.Value; // Query is executed here + List suggestions = suggest["Name"].Suggestions; + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_9 + // Define a lazy DocumentQuery + Lazy> lazySuggestions = session.Advanced + .DocumentQuery() + .SuggestUsing(builder => builder.ByField("Name", "chaig")) + // Add a call to 'ExecuteLazy' + .ExecuteLazy(); + + Dictionary suggest = lazySuggestions.Value; // DocumentQuery is executed here + List suggestions = suggest["FullName"].Suggestions; + #endregion + } + + #region the_facets + // The facets definition used in the facets query: + List facetsDefinition = new List + { + new Facet + { + FieldName = "CategoryName", + DisplayFieldName = "Product Category" + }, + new RangeFacet + { + Ranges = + { + product => product.PricePerUnit < 25, + product => product.PricePerUnit >= 25 && product.PricePerUnit < 50, + product => product.PricePerUnit >= 50 && product.PricePerUnit < 100, + product => product.PricePerUnit >= 100 + }, + DisplayFieldName = "Price per Unit" + } + }; + #endregion + + using (var session = store.OpenSession()) + { + #region lazy_10 + // Define a lazy facets query + Lazy> lazyFacets = session + .Query() + .AggregateBy(facetsDefinition) + // Add a call to 'ExecuteLazy' + .ExecuteLazy(); + + Dictionary facets = lazyFacets.Value; // Query is executed here + + FacetResult categoryResults = facets["Product Category"]; + FacetResult priceResults = facets["Price per Unit"]; + #endregion + } + + using (var asyncSession = store.OpenSession()) + { + #region lazy_11 + // Define a lazy DocumentQuery + Lazy>> lazyFacets = asyncSession + .Query() + .AggregateBy(facetsDefinition) + // Add a call to 'ExecuteLazyAsync' + .ExecuteLazyAsync(); + + Dictionary facets = await lazyFacets.Value; // Query is executed here + + FacetResult categoryResults = facets["Product Category"]; + FacetResult priceResults = facets["Price per Unit"]; + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_12 + // Define a lazy DocumentQuery + Lazy> lazyFacets = session.Advanced + .DocumentQuery() + .AggregateBy(facetsDefinition) + // Add a call to 'ExecuteLazy' + .ExecuteLazy(); + + Dictionary facets = lazyFacets.Value; // DocumentQuery is executed here + + FacetResult categoryResults = facets["Product Category"]; + FacetResult priceResults = facets["Price per Unit"]; + #endregion + } + } + } + + private interface IFoo + { + #region syntax_1 + // Lazy query overloads: + Lazy> Lazily(); + Lazy> Lazily(Action> onEval); + + Lazy>> LazilyAsync(); + Lazy>> LazilyAsync(Action> onEval); + #endregion + + #region syntax_2 + // Lazy count query overloads: + Lazy CountLazily(); + Lazy> CountLazilyAsync(CancellationToken token = default(CancellationToken)); + #endregion + + #region syntax_3 + // Lazy suggestions query overloads: + Lazy> + ExecuteLazy(Action> onEval = null); + + Lazy>> + ExecuteLazyAsync(Action> onEval = null, + CancellationToken token = default); + #endregion + + #region syntax_4 + // Lazy facets query overloads: + Lazy> + ExecuteLazy(Action> onEval = null); + + Lazy>> + ExecuteLazyAsync(Action> onEval = null, + CancellationToken token = default); + #endregion + } + } + + #region the_index + // The index definition used in the facets query: + public class Products_ByCategoryAndPrice : + AbstractIndexCreationTask + { + // The IndexEntry class defines the index-fields + public class IndexEntry + { + public string CategoryName { get; set; } + public decimal PricePerUnit { get; set; } + } + + public Products_ByCategoryAndPrice() + { + // The 'Map' function defines the content of the index-fields + Map = products => from product in products + select new IndexEntry + { + CategoryName = LoadDocument(product.Category).Name, + PricePerUnit = product.PricePerUnit + }; + } + } + #endregion +} diff --git a/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/Indexes/Querying/QueryIndex.cs b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/Indexes/Querying/QueryIndex.cs index 719284fee9..cbc1ca65f2 100644 --- a/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/Indexes/Querying/QueryIndex.cs +++ b/Documentation/5.2/Samples/csharp/Raven.Documentation.Samples/Indexes/Querying/QueryIndex.cs @@ -13,7 +13,7 @@ namespace Raven.Documentation.Samples.Indexes.Querying public class Employees_ByName : AbstractIndexCreationTask { - // The IndexEntry class defines the index-fields. + // The IndexEntry class defines the index-fields public class IndexEntry { public string FirstName { get; set; } diff --git a/Documentation/5.2/Samples/java/src/test/java/net/ravendb/ClientApi/Session/Querying/HowToPerformQueriesLazily.java b/Documentation/5.2/Samples/java/src/test/java/net/ravendb/ClientApi/Session/Querying/HowToPerformQueriesLazily.java new file mode 100644 index 0000000000..1f4e1c4a8b --- /dev/null +++ b/Documentation/5.2/Samples/java/src/test/java/net/ravendb/ClientApi/Session/Querying/HowToPerformQueriesLazily.java @@ -0,0 +1,100 @@ +package net.ravendb.ClientApi.Session.Querying; + +import net.ravendb.client.documents.DocumentStore; +import net.ravendb.client.documents.IDocumentStore; +import net.ravendb.client.documents.Lazy; +import net.ravendb.client.documents.queries.Query; +import net.ravendb.client.documents.queries.facets.FacetResult; +import net.ravendb.client.documents.queries.suggestions.SuggestionResult; +import net.ravendb.client.documents.session.IDocumentSession; + +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +public class HowToPerformQueriesLazily { + + private interface IFoo { + //region lazy_1 + Lazy> lazily(); + + Lazy> lazily(Consumer> onEval); + //endregion + + //region lazy_4 + Lazy countLazily(); + //endregion + + //region lazy_6 + Lazy> executeLazy(); + + Lazy> executeLazy(Consumer> onEval); + //endregion + } + + private interface IFoo2 { + //region lazy_8 + Lazy> executeLazy(); + + Lazy> executeLazy(Consumer> onEval); + //endregion + } + + private static class Employee { + + } + + private static class Camera { + + } + + public HowToPerformQueriesLazily() { + try (IDocumentStore store = new DocumentStore()) { + try (IDocumentSession session = store.openSession()) { + //region lazy_2 + Lazy> employeesLazy = session + .query(Employee.class) + .whereEquals("FirstName", "Robert") + .lazily(); + + List employees = employeesLazy.getValue(); // query will be executed here + //endregion + } + + try (IDocumentSession session = store.openSession()) { + //region lazy_5 + Lazy countLazy = session + .query(Employee.class) + .whereEquals("FirstName", "Robert") + .countLazily(); + + Integer count = countLazy.getValue(); // query will be executed here + //endregion + } + + try (IDocumentSession session = store.openSession()) { + //region lazy_7 + Lazy> suggestLazy = session + .query(Employee.class, Query.index("Employees_ByFullName")) + .suggestUsing(builder -> builder.byField("FullName", "johne")) + .executeLazy(); + + Map suggest = suggestLazy.getValue(); // query will be executed here + List suggestions = suggest.get("FullName").getSuggestions(); + //endregion + } + + try (IDocumentSession session = store.openSession()) { + //region lazy_9 + Lazy> facetsLazy = session + .query(Camera.class, Query.index("Camera/Costs")) + .aggregateUsing("facets/CameraFacets") + .executeLazy(); + + Map facets = facetsLazy.getValue(); // query will be executed here + FacetResult results = facets.get("manufacturer"); + //endregion + } + } + } +} diff --git a/Documentation/5.2/Samples/nodejs/ClientApi/Session/HowTo/lazy.js b/Documentation/5.2/Samples/nodejs/ClientApi/Session/HowTo/lazy.js index f68bdb30e8..311e99a378 100644 --- a/Documentation/5.2/Samples/nodejs/ClientApi/Session/HowTo/lazy.js +++ b/Documentation/5.2/Samples/nodejs/ClientApi/Session/HowTo/lazy.js @@ -134,19 +134,51 @@ async function lazyExamples() { //endregion } { - //region lazy_executeAllPendingLazyOperations + //region lazy_ExecuteAll_Implicit // Define multiple lazy requests const lazyUser1 = session.advanced.lazily.load("users/1-A"); const lazyUser2 = session.advanced.lazily.load("users/2-A"); - const lazyEmployees = session.query({ collection: "employees" }).lazily(); + + const lazyEmployees = session.query({ collection: "employees" }) + .lazily(); + const lazyProducts = session.query({ collection: "products" }) + .search("Name", "Ch*") + .lazily(); + + // Accessing the value of ANY of the lazy instances will trigger + // the execution of ALL pending lazy requests held up by the session + // This is done in a SINGLE server call + const user1 = await lazyUser1.getValue(); + + // ALL the other values are now also available + // No additional server calls are made when accessing these values + const user2 = await lazyUser2.getValue(); + const employees = await lazyEmployees.getValue(); + const products = await lazyProducts.getValue(); + //endregion + } + { + //region lazy_ExecuteAll_Explicit + // Define multiple lazy requests + const lazyUser1 = session.advanced.lazily.load("users/1-A"); + const lazyUser2 = session.advanced.lazily.load("users/2-A"); + + const lazyEmployees = session.query({ collection: "employees" }) + .lazily(); + const lazyProducts = session.query({ collection: "products" }) + .search("Name", "Ch*") + .lazily(); - // Execute all pending lazy operations + // Explicitly call 'executeAllPendingLazyOperations' + // ALL pending lazy requests held up by the session will be executed in a SINGLE server call await session.advanced.eagerly.executeAllPendingLazyOperations(); - // All values are now available + // ALL values are now available + // No additional server calls are made when accessing the values const user1 = await lazyUser1.getValue(); const user2 = await lazyUser2.getValue(); const employees = await lazyEmployees.getValue(); + const products = await lazyProducts.getValue(); //endregion } { diff --git a/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/howToPerformQueriesLazily.js b/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/howToPerformQueriesLazily.js new file mode 100644 index 0000000000..fffbd4a164 --- /dev/null +++ b/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/howToPerformQueriesLazily.js @@ -0,0 +1,112 @@ +import { DocumentStore, AbstractJavaScriptIndexCreationTask, Facet, RangeFacet } from "ravendb"; + +const documentStore = new DocumentStore(); +const session = documentStore.openSession(); + +async function lazyExamples() { + { + //region lazy_1 + // Define a lazy query + const lazyEmployees = session + .query({ collection: "Employees" }) + .whereEquals("FirstName", "Robert") + // Add a call to 'lazily' + .lazily(); + + const employees = await lazyEmployees.getValue(); // Query is executed here + //endregion + } + + { + //region lazy_2 + // Define a lazy count query + const lazyCount = session + .query({ collection: "Employees" }) + .whereEquals("FirstName", "Robert") + // Add a call to 'countLazily' + .countLazily(); + + const count = await lazyCount.getValue(); // Query is executed here + //endregion + } + + { + //region lazy_3 + // Define a lazy suggestion query + const lazySuggestions = session + .query({ collection: "Products" }) + .suggestUsing(builder => builder.byField("Name", "chaig")) + // Add a call to 'executeLazy' + .executeLazy(); + + const suggestResult = await lazySuggestions.getValue(); // Query is executed here + const suggestions = suggestResult["Name"].suggestions; + //endregion + } + + { + //region lazy_4 + // The facets definition used in the facets query: + // =============================================== + const categoryNameFacet = new Facet(); + + categoryNameFacet.fieldName = "categoryName"; + categoryNameFacet.displayFieldName = "Product Category"; + + const rangeFacet = new RangeFacet(); + rangeFacet.ranges = [ + "pricePerUnit < " + 25, + "pricePerUnit >= " + 25 + " and pricePerUnit < " + 50, + "pricePerUnit >= " + 50 + " and pricePerUnit < " + 100, + "pricePerUnit >= " + 100 + ]; + rangeFacet.displayFieldName = 'Price per Unit'; + + const facetsDefinition = [categoryNameFacet, rangeFacet]; + + // The lazy factes query: + // ====================== + const lazyFacets = session + .query({ indexName: "Products/ByCategoryAndPrice" }) + .aggregateBy(...facetsDefinition) + // Add a call to 'executeLazy' + .executeLazy(); + + const facets = await lazyFacets.getValue(); // Query is executed here + + const categoryResults = facets["Product Category"]; + const priceResults = facets["Price per Unit"]; + //endregion + } +} + +{ + //region the_index + // The index definition used in the facets query: + class Products_ByCategoryAndPrice extends AbstractJavaScriptIndexCreationTask { + constructor() { + super(); + + const { load } = this.mapUtils(); + + this.map("Products", product => { + return { + categoryName: load(product.Category, "Categories").Name, + pricePerUnit: product.PricePerUnit + } + }); + } + } + //endregion +} + +{ + //region syntax + lazily(); + lazily(onEval); + + countLazily(); + + executeLazy(); + //endregion +} diff --git a/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/workWithSuggestions.js b/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/workWithSuggestions.js index 5dd67c9c17..bfb6d1c44a 100644 --- a/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/workWithSuggestions.js +++ b/Documentation/5.2/Samples/nodejs/ClientApi/Session/Querying/workWithSuggestions.js @@ -9,7 +9,7 @@ async function suggestions() { // This dynamic query on the 'Products' collection has NO resulting documents const products = await session .query({ collection: "Products" }) - .where(x => x.Name == "chaig") + .whereEquals("Name", "Chai") .all(); //endregion } diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/.docs.json b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/.docs.json index e86101a892..eda0d8b7c7 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/.docs.json +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/.docs.json @@ -25,7 +25,7 @@ }, { "Path": "perform-operations-lazily.markdown", - "Name": "...perform operations lazily", + "Name": "...perform requests lazily", "DiscussionId": "7a54c2fc-67ee-40e6-94b5-1266e990cf57", "Mappings": [ { diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown index 13e98343f8..14cd80c0e7 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.dotnet.markdown @@ -1,26 +1,41 @@ -# How to Perform Operations Lazily - +# Perform requests lazily --- {NOTE: } -* **Defining a lazy operation** allows deferring the execution of the operation until it is needed. +* __Lazy request__: + + * You can define a lazy request within a session (e.g. a lazy-query or a lazy-load request) + and defer its execution until actually needed. + + * The lazy request definition is stored in the session and a `Lazy` instance is returned. + The request will be sent to the server and executed only when you access the value of this instance. + +* __Multiple lazy requests__: -* Multiple pending lazy operations can be executed together, see below. + * Multiple lazy requests can be defined within the same session. + + * When triggering the deferred execution (whether implicitly or explicitly), + ALL pending lazy requests held up by the session will be sent to the server in a single call. + This can help reduce the number of remote calls made to the server over the network. * In this page: - * [Operations that can be executed lazily](../../../client-api/session/how-to/perform-operations-lazily#operations-that-can-be-executed-lazily) - * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) - * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) - * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) - * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) - * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) - * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) - * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) - * [Execute all pending lazy operations](../../../client-api/session/how-to/perform-operations-lazily#execute-all-pending-lazy-operations) + * [Requests that can be executed lazily:](../../../client-api/session/how-to/perform-operations-lazily#requests-that-can-be-executed-lazily) + * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) + * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) + * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) + * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) + * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) + * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) + * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) + * [Multiple lazy requests](../../../client-api/session/how-to/perform-operations-lazily#multiple-lazy-requests) + * [Execute all requests - implicitly](../../../client-api/session/how-to/perform-operations-lazily#implicit) + * [Execute all requests - explicitly](../../../client-api/session/how-to/perform-operations-lazily#explicit) {NOTE/} +--- + {PANEL: Operations that can be executed lazily} {NOTE: } @@ -39,8 +54,8 @@ Loading entities with include can be executed __lazily__. {CODE-TABS} -{CODE-TAB:csharp:Lazy-load-with-include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} -{CODE-TAB:csharp:The-document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:Lazy_load_with_include lazy_LoadWithInclude@ClientApi\Session\HowTo\Lazy.cs /} +{CODE-TAB:csharp:The_document lazy_productClass@ClientApi\Session\HowTo\Lazy.cs /} {CODE-TABS/} {NOTE/} @@ -70,7 +85,7 @@ {NOTE: }
__Run query__ -* A Query can be executing a __lazily__. +* A Query can be executed __lazily__. Learn more about running queries lazily in [lazy queries](../../../client-api/session/querying/how-to-perform-queries-lazily). {CODE lazy_Query@ClientApi\Session\HowTo\Lazy.cs /} @@ -94,11 +109,21 @@ {PANEL/} -{PANEL: Execute all pending lazy operations} +{PANEL: Multiple lazy requests } -* Use `ExecuteAllPendingLazyOperations` to execute **all** pending lazy operations at once. +{NOTE: } + __Execute all requests - implicitly__ -{CODE lazy_ExecuteAllPendingLazyOperations@ClientApi\Session\HowTo\Lazy.cs /} +{CODE lazy_ExecuteAll_Implicit@ClientApi\Session\HowTo\Lazy.cs /} + +{NOTE/} + +{NOTE: } + __Execute all requests - explicitly__ + +{CODE lazy_ExecuteAll_Explicit@ClientApi\Session\HowTo\Lazy.cs /} + +{NOTE/} {PANEL/} diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown index 435482bd64..db31b993eb 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/how-to/perform-operations-lazily.js.markdown @@ -1,26 +1,41 @@ -# How to Perform Operations Lazily - +# Perform requests lazily --- {NOTE: } -* **Defining a lazy operation** allows deferring the execution of the operation until it is needed. +* __Lazy request__: + + * You can define a lazy request within a session (e.g. a lazy-query or a lazy-load request) + and defer its execution until actually needed. + + * The lazy request definition is stored in the session and a `Lazy` instance is returned. + The request will be sent to the server and executed only when you access the value of this instance. + +* __Multiple lazy requests__: -* Multiple pending lazy operations can be executed together, see below. + * Multiple lazy requests can be defined within the same session. + + * When triggering the deferred execution (whether implicitly or explicitly), + ALL pending lazy requests held up by the session will be sent to the server in a single call. + This can help reduce the number of remote calls made to the server over the network. * In this page: - * [Operations that can be executed lazily](../../../client-api/session/how-to/perform-operations-lazily#operations-that-can-be-executed-lazily) - * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) - * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) - * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) - * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) - * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) - * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) - * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) - * [Execute all pending lazy operations](../../../client-api/session/how-to/perform-operations-lazily#execute-all-pending-lazy-operations) + * [Requests that can be executed lazily:](../../../client-api/session/how-to/perform-operations-lazily#requests-that-can-be-executed-lazily) + * [Load entities](../../../client-api/session/how-to/perform-operations-lazily#loadEntities) + * [Load entities with include](../../../client-api/session/how-to/perform-operations-lazily#loadWithInclude) + * [Load entities starting with](../../../client-api/session/how-to/perform-operations-lazily#loadStartingWith) + * [Conditional load](../../../client-api/session/how-to/perform-operations-lazily#conditionalLoad) + * [Run query](../../../client-api/session/how-to/perform-operations-lazily#runQuery) + * [Get revisions](../../../client-api/session/how-to/perform-operations-lazily#getRevisions) + * [Get compare-exchange value](../../../client-api/session/how-to/perform-operations-lazily#getCompareExchange) + * [Multiple lazy requests](../../../client-api/session/how-to/perform-operations-lazily#multiple-lazy-requests) + * [Execute all requests - implicitly](../../../client-api/session/how-to/perform-operations-lazily#implicit) + * [Execute all requests - explicitly](../../../client-api/session/how-to/perform-operations-lazily#explicit) {NOTE/} +--- + {PANEL: Operations that can be executed lazily} {NOTE: } @@ -39,8 +54,8 @@ Loading entities with include can be executed __lazily__. {CODE-TABS} -{CODE-TAB:nodejs:Lazy-load-with-include lazy_loadWithInclude@client-api\Session\HowTo\lazy.js /} -{CODE-TAB:nodejs:Sample-document lazy_productClass@client-api\Session\HowTo\lazy.js /} +{CODE-TAB:nodejs:Lazy_load_with_include lazy_loadWithInclude@client-api\Session\HowTo\lazy.js /} +{CODE-TAB:nodejs:The_document lazy_productClass@client-api\Session\HowTo\lazy.js /} {CODE-TABS/} {NOTE/} @@ -70,7 +85,7 @@ {NOTE: } __Run query__ -* A Query can be executing a __lazily__. +* A Query can be executed __lazily__. Learn more about running queries lazily in [lazy queries](../../../client-api/session/querying/how-to-perform-queries-lazily). {CODE:nodejs lazy_query@client-api\Session\HowTo\lazy.js /} @@ -94,11 +109,21 @@ {PANEL/} -{PANEL: Execute all pending lazy operations} +{PANEL: Multiple lazy requests } -* Use `executeAllPendingLazyOperations` to execute **all** pending lazy operations at once. +{NOTE: } + __Execute all requests - implicitly__ -{CODE:nodejs lazy_executeAllPendingLazyOperations@client-api\Session\HowTo\lazy.js /} +{CODE:nodejs lazy_ExecuteAll_Implicit@client-api\Session\HowTo\lazy.js /} + +{NOTE/} + +{NOTE: } + __Execute all requests - explicitly__ + +{CODE:nodejs lazy_ExecuteAll_Explicit@client-api\Session\HowTo\lazy.js /} + +{NOTE/} {PANEL/} diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown index c2ea2171b8..ef277fe7b1 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.dotnet.markdown @@ -3,17 +3,19 @@ {NOTE: } -There are several methods with many overloads that allow users to download documents -from the database and convert them to entities. This article will cover the following -methods: - -- [Load](../../client-api/session/loading-entities#load) -- [Load with Includes](../../client-api/session/loading-entities#load-with-includes) -- [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) -- [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) -- [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) -- [Stream](../../client-api/session/loading-entities#stream) -- [IsLoaded](../../client-api/session/loading-entities#isloaded) +* There are several methods that allow users to load documents from the database and convert them to entities. + +* This article covers the following methods: + + - [Load](../../client-api/session/loading-entities#load) + - [Load with Includes](../../client-api/session/loading-entities#load-with-includes) + - [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) + - [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) + - [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) + - [Stream](../../client-api/session/loading-entities#stream) + - [IsLoaded](../../client-api/session/loading-entities#isloaded) + +* For loading entities lazily see [perform requests lazily](../../client-api/session/how-to/perform-operations-lazily). {NOTE/} diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown index 8f533d76de..b33d77365a 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/loading-entities.js.markdown @@ -1,14 +1,25 @@ # Session: Loading Entities +--- -There are various methods with many overloads that allow users to download documents from a database and convert them to entities. This article will cover the following methods: +{NOTE: } -- [Load](../../client-api/session/loading-entities#load) -- [Load with Includes](../../client-api/session/loading-entities#load-with-includes) -- [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) -- [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) -- [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) -- [IsLoaded](../../client-api/session/loading-entities#isloaded) -- [Stream](../../client-api/session/loading-entities#stream) +* There are several methods that allow users to load documents from the database and convert them to entities. + +* This article covers the following methods: + + - [Load](../../client-api/session/loading-entities#load) + - [Load with Includes](../../client-api/session/loading-entities#load-with-includes) + - [Load - multiple entities](../../client-api/session/loading-entities#load---multiple-entities) + - [LoadStartingWith](../../client-api/session/loading-entities#loadstartingwith) + - [ConditionalLoad](../../client-api/session/loading-entities#conditionalload) + - [IsLoaded](../../client-api/session/loading-entities#isloaded) + - [Stream](../../client-api/session/loading-entities#stream) + +* For loading entities lazily see [perform requests lazily](../../client-api/session/how-to/perform-operations-lazily). + +{NOTE/} + +--- {PANEL:Load} diff --git a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/querying/.docs.json b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/querying/.docs.json index 9bfb10e1a3..02bea03a93 100644 --- a/Documentation/5.3/Raven.Documentation.Pages/client-api/session/querying/.docs.json +++ b/Documentation/5.3/Raven.Documentation.Pages/client-api/session/querying/.docs.json @@ -23,7 +23,7 @@ }, { "Path": "how-to-stream-query-results.markdown", - "Name": "How to Stream Query Results", + "Name": "Stream Query Results", "DiscussionId": "c96a370e-8d0d-4e8f-93b3-03a8105e8b0e", "Mappings": [ { @@ -34,7 +34,7 @@ }, { "Path": "how-to-customize-query.markdown", - "Name": "How to Customize Query", + "Name": "Customize Query", "DiscussionId": "73dfb483-1fca-4fca-a1a4-15c7366b4775", "Mappings": [] }, @@ -72,7 +72,7 @@ }, { "Path": "how-to-make-a-spatial-query.markdown", - "Name": "How to Make a Spatial Query", + "Name": "Make a Spatial Query", "DiscussionId": "b62de172-77e9-4241-a525-9ba6cc027860", "Mappings": [ { @@ -89,13 +89,13 @@ }, { "Path": "how-to-filter-by-field.markdown", - "Name": "How to Filter by Field Presence", + "Name": "Filter by Field Presence", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, { "Path": "how-to-filter-by-non-existing-field.markdown", - "Name": "How to Filter by Non-Existing Field", + "Name": "Filter by Non-Existing Field", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, @@ -112,7 +112,7 @@ }, { "Path": "how-to-perform-queries-lazily.markdown", - "Name": "How to Perform Queries Lazily", + "Name": "Perform a Lazy Query", "DiscussionId": "a359f844-7193-4228-98e0-81a07e561a8b", "Mappings": [ { diff --git a/Documentation/5.3/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs b/Documentation/5.3/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs index b406f7f31d..963d738077 100644 --- a/Documentation/5.3/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs +++ b/Documentation/5.3/Samples/csharp/Raven.Documentation.Samples/ClientApi/Session/HowTo/Lazy.cs @@ -116,7 +116,7 @@ public Lazy() using (var session = store.OpenSession()) { #region lazy_Revisions - var lazyRevisions = session + Lazy> lazyRevisions = session // Add a call to Lazily .Advanced.Revisions.Lazily // Revisions will Not be fetched here, no server call is made @@ -140,7 +140,7 @@ public Lazy() session.SaveChanges(); // Get the compare-exchange value lazily: - var lazyCmpXchg = session + Lazy> lazyCmpXchg = session // Add a call to Lazily .Advanced.ClusterTransaction.Lazily // Compare-exchange values will Not be fetched here, no server call is made @@ -156,19 +156,53 @@ public Lazy() using (var session = store.OpenSession()) { - #region lazy_ExecuteAllPendingLazyOperations + #region lazy_ExecuteAll_Implicit // Define multiple lazy requests Lazy lazyUser1 = session.Advanced.Lazily.Load("users/1-A"); Lazy lazyUser2 = session.Advanced.Lazily.Load("users/2-A"); - Lazy> lazyEmployees = session.Query().Lazily(); + + Lazy> lazyEmployees = session.Query() + .Lazily(); + Lazy> lazyProducts = session.Query() + .Search(x => x.Name, "Ch*") + .Lazily(); + + // Accessing the value of ANY of the lazy instances will trigger + // the execution of ALL pending lazy requests held up by the session + // This is done in a SINGLE server call + User user1 = lazyUser1.Value; + + // ALL the other values are now also available + // No additional server calls are made when accessing these values + User user2 = lazyUser2.Value; + IEnumerable employees = lazyEmployees.Value; + IEnumerable products = lazyProducts.Value; + #endregion + } + + using (var session = store.OpenSession()) + { + #region lazy_ExecuteAll_Explicit + // Define multiple lazy requests + Lazy lazyUser1 = session.Advanced.Lazily.Load("users/1-A"); + Lazy lazyUser2 = session.Advanced.Lazily.Load("users/2-A"); + + Lazy> lazyEmployees = session.Query() + .Lazily(); + Lazy> lazyProducts = session.Query() + .Search(x => x.Name, "Ch*") + .Lazily(); - // Execute all pending lazy operations + // Explicitly call 'ExecuteAllPendingLazyOperations' + // ALL pending lazy requests held up by the session will be executed in a SINGLE server call session.Advanced.Eagerly.ExecuteAllPendingLazyOperations(); - // All values are now available + // ALL values are now available + // No additional server calls are made when accessing the values User user1 = lazyUser1.Value; User user2 = lazyUser2.Value; IEnumerable employees = lazyEmployees.Value; + IEnumerable products = lazyProducts.Value; #endregion } } diff --git a/Documentation/5.3/Samples/nodejs/client-api/Session/HowTo/lazy.js b/Documentation/5.3/Samples/nodejs/client-api/Session/HowTo/lazy.js index f68bdb30e8..e848cb16a6 100644 --- a/Documentation/5.3/Samples/nodejs/client-api/Session/HowTo/lazy.js +++ b/Documentation/5.3/Samples/nodejs/client-api/Session/HowTo/lazy.js @@ -134,19 +134,51 @@ async function lazyExamples() { //endregion } { - //region lazy_executeAllPendingLazyOperations + //region lazy_ExecuteAll_Implicit // Define multiple lazy requests const lazyUser1 = session.advanced.lazily.load("users/1-A"); const lazyUser2 = session.advanced.lazily.load("users/2-A"); - const lazyEmployees = session.query({ collection: "employees" }).lazily(); - // Execute all pending lazy operations + const lazyEmployees = session.query({ collection: "employees" }) + .lazily(); + const lazyProducts = session.query({ collection: "products" }) + .search("Name", "Ch*") + .lazily(); + + // Accessing the value of ANY of the lazy instances will trigger + // the execution of ALL pending lazy requests held up by the session + // This is done in a SINGLE server call + const user1 = await lazyUser1.getValue(); + + // ALL the other values are now also available + // No additional server calls are made when accessing these values + const user2 = await lazyUser2.getValue(); + const employees = await lazyEmployees.getValue(); + const products = await lazyProducts.getValue(); + //endregion + } + { + //region lazy_ExecuteAll_Explicit + // Define multiple lazy requests + const lazyUser1 = session.advanced.lazily.load("users/1-A"); + const lazyUser2 = session.advanced.lazily.load("users/2-A"); + + const lazyEmployees = session.query({ collection: "employees" }) + .lazily(); + const lazyProducts = session.query({ collection: "products" }) + .search("Name", "Ch*") + .lazily(); + + // Explicitly call 'executeAllPendingLazyOperations' + // ALL pending lazy requests held up by the session will be executed in a SINGLE server call await session.advanced.eagerly.executeAllPendingLazyOperations(); - // All values are now available + // ALL values are now available + // No additional server calls are made when accessing the values const user1 = await lazyUser1.getValue(); const user2 = await lazyUser2.getValue(); const employees = await lazyEmployees.getValue(); + const products = await lazyProducts.getValue(); //endregion } { diff --git a/Documentation/5.4/Raven.Documentation.Pages/client-api/session/how-to/.docs.json b/Documentation/5.4/Raven.Documentation.Pages/client-api/session/how-to/.docs.json index 89d3a488f4..826e8b74a5 100644 --- a/Documentation/5.4/Raven.Documentation.Pages/client-api/session/how-to/.docs.json +++ b/Documentation/5.4/Raven.Documentation.Pages/client-api/session/how-to/.docs.json @@ -25,7 +25,7 @@ }, { "Path": "perform-operations-lazily.markdown", - "Name": "...perform operations lazily", + "Name": "...perform requests lazily", "DiscussionId": "7a54c2fc-67ee-40e6-94b5-1266e990cf57", "Mappings": [ { diff --git a/Documentation/5.4/Raven.Documentation.Pages/client-api/session/querying/.docs.json b/Documentation/5.4/Raven.Documentation.Pages/client-api/session/querying/.docs.json index a242bfd670..035bcf2f4c 100644 --- a/Documentation/5.4/Raven.Documentation.Pages/client-api/session/querying/.docs.json +++ b/Documentation/5.4/Raven.Documentation.Pages/client-api/session/querying/.docs.json @@ -23,7 +23,7 @@ }, { "Path": "how-to-stream-query-results.markdown", - "Name": "How to Stream Query Results", + "Name": "Stream Query Results", "DiscussionId": "c96a370e-8d0d-4e8f-93b3-03a8105e8b0e", "Mappings": [ { @@ -34,7 +34,7 @@ }, { "Path": "how-to-customize-query.markdown", - "Name": "How to Customize Query", + "Name": "Customize Query", "DiscussionId": "73dfb483-1fca-4fca-a1a4-15c7366b4775", "Mappings": [] }, @@ -72,7 +72,7 @@ }, { "Path": "how-to-make-a-spatial-query.markdown", - "Name": "How to Make a Spatial Query", + "Name": "Make a Spatial Query", "DiscussionId": "b62de172-77e9-4241-a525-9ba6cc027860", "Mappings": [ { @@ -89,13 +89,13 @@ }, { "Path": "how-to-filter-by-field.markdown", - "Name": "How to Filter by Field Presence", + "Name": "Filter by Field Presence", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, { "Path": "how-to-filter-by-non-existing-field.markdown", - "Name": "How to Filter by Non-Existing Field", + "Name": "Filter by Non-Existing Field", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, @@ -112,7 +112,7 @@ }, { "Path": "how-to-perform-queries-lazily.markdown", - "Name": "How to Perform Queries Lazily", + "Name": "Perform a Lazy Query", "DiscussionId": "a359f844-7193-4228-98e0-81a07e561a8b", "Mappings": [ { diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/how-to/.docs.json b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/how-to/.docs.json index 89d3a488f4..826e8b74a5 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/how-to/.docs.json +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/how-to/.docs.json @@ -25,7 +25,7 @@ }, { "Path": "perform-operations-lazily.markdown", - "Name": "...perform operations lazily", + "Name": "...perform requests lazily", "DiscussionId": "7a54c2fc-67ee-40e6-94b5-1266e990cf57", "Mappings": [ { diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/.docs.json b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/.docs.json index 7c422182f8..dc6f388361 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/.docs.json +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/.docs.json @@ -28,7 +28,7 @@ }, { "Path": "how-to-stream-query-results.markdown", - "Name": "How to Stream Query Results", + "Name": "Stream Query Results", "DiscussionId": "c96a370e-8d0d-4e8f-93b3-03a8105e8b0e", "Mappings": [ { @@ -39,7 +39,7 @@ }, { "Path": "how-to-customize-query.markdown", - "Name": "How to Customize Query", + "Name": "Customize Query", "DiscussionId": "73dfb483-1fca-4fca-a1a4-15c7366b4775", "Mappings": [] }, @@ -77,7 +77,7 @@ }, { "Path": "how-to-make-a-spatial-query.markdown", - "Name": "How to Make a Spatial Query", + "Name": "Make a Spatial Query", "DiscussionId": "b62de172-77e9-4241-a525-9ba6cc027860", "Mappings": [ { @@ -94,13 +94,13 @@ }, { "Path": "how-to-filter-by-field.markdown", - "Name": "How to Filter by Field Presence", + "Name": "Filter by Field Presence", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, { "Path": "how-to-filter-by-non-existing-field.markdown", - "Name": "How to Filter by Non-Existing Field", + "Name": "Filter by Non-Existing Field", "DiscussionId": "bda0ec07-d0f9-46a0-bab7-ca733f692533", "Mappings": [] }, @@ -117,7 +117,7 @@ }, { "Path": "how-to-perform-queries-lazily.markdown", - "Name": "How to Perform Queries Lazily", + "Name": "Perform a Lazy Query", "DiscussionId": "a359f844-7193-4228-98e0-81a07e561a8b", "Mappings": [ { diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json index d8bb75f036..a5fb6200a7 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/.docs.json @@ -1,13 +1,13 @@ [ { "Path": "include-explanations.markdown", - "Name": "How to Include Query Explanations", + "Name": "Include Query Explanations", "DiscussionId": "2d056281-2f65-4180-a3e1-a6348ec2d230", "Mappings": [] }, { "Path": "query-timings.markdown", - "Name": "How to Include Query Timings", + "Name": "Include Query Timings", "DiscussionId": "873da629-f825-4378-bac9-87153227a41b", "Mappings": [] } diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown index 38bee661c4..c567397d8c 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.dotnet.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings --- diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown index 565584a03e..301cdc6cdb 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.java.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings --- diff --git a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown index bc12189820..d8257a6599 100644 --- a/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown +++ b/Documentation/6.0/Raven.Documentation.Pages/client-api/session/querying/debugging/query-timings.js.markdown @@ -1,4 +1,4 @@ -# How to Include Query Timings +# Include Query Timings ---