forked from ravendb/ravendb
/
IDocumentQueryCustomization.cs
197 lines (172 loc) · 9.08 KB
/
IDocumentQueryCustomization.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
//-----------------------------------------------------------------------
// <copyright file="IDocumentQueryCustomization.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using Raven.Abstractions.Data;
using Raven.Abstractions.Indexing;
namespace Raven.Client
{
/// <summary>
/// Customize the document query
/// </summary>
public interface IDocumentQueryCustomization
{
/// <summary>
/// Instructs the query to wait for non stale results as of the last write made by any session belonging to the
/// current document store.
/// This ensures that you'll always get the most relevant results for your scenarios using simple indexes (map only or dynamic queries).
/// However, when used to query map/reduce indexes, it does NOT guarantee that the document that this etag belong to is actually considered for the results.
/// </summary>
IDocumentQueryCustomization WaitForNonStaleResultsAsOfLastWrite();
/// <summary>
/// Instructs the query to wait for non stale results as of the last write made by any session belonging to the
/// current document store.
/// This ensures that you'll always get the most relevant results for your scenarios using simple indexes (map only or dynamic queries).
/// However, when used to query map/reduce indexes, it does NOT guarantee that the document that this etag belong to is actually considered for the results.
/// </summary>
IDocumentQueryCustomization WaitForNonStaleResultsAsOfLastWrite(TimeSpan waitTimeout);
/// <summary>
/// Instructs the query to wait for non stale results as of now.
/// </summary>
/// <returns></returns>
IDocumentQueryCustomization WaitForNonStaleResultsAsOfNow();
/// <summary>
/// Instructs the query to wait for non stale results as of now for the specified timeout.
/// </summary>
/// <param name="waitTimeout">The wait timeout.</param>
/// <returns></returns>
IDocumentQueryCustomization WaitForNonStaleResultsAsOfNow(TimeSpan waitTimeout);
/// <summary>
/// Instructs the query to wait for non stale results as of the cutoff date.
/// </summary>
/// <param name="cutOff">The cut off.</param>
/// <returns></returns>
IDocumentQueryCustomization WaitForNonStaleResultsAsOf(DateTime cutOff);
/// <summary>
/// Instructs the query to wait for non stale results as of the cutoff date for the specified timeout
/// </summary>
/// <param name="cutOff">The cut off.</param>
/// <param name="waitTimeout">The wait timeout.</param>
IDocumentQueryCustomization WaitForNonStaleResultsAsOf(DateTime cutOff, TimeSpan waitTimeout);
/// <summary>
/// Instructs the query to wait for non stale results as of the cutoff etag.
/// </summary>
/// <param name="cutOffEtag">The cut off etag.</param>
IDocumentQueryCustomization WaitForNonStaleResultsAsOf(Guid cutOffEtag);
/// <summary>
/// Instructs the query to wait for non stale results as of the cutoff etag for the specified timeout.
/// </summary>
/// <param name="cutOffEtag">The cut off etag.</param>
/// <param name="waitTimeout">The wait timeout.</param>
IDocumentQueryCustomization WaitForNonStaleResultsAsOf(Guid cutOffEtag, TimeSpan waitTimeout);
/// <summary>
/// EXPERT ONLY: Instructs the query to wait for non stale results.
/// This shouldn't be used outside of unit tests unless you are well aware of the implications
/// </summary>
IDocumentQueryCustomization WaitForNonStaleResults();
/// <summary>
/// Includes the specified path in the query, loading the document specified in that path
/// </summary>
/// <typeparam name="TResult">The type of the object that holds the id that you want to include.</typeparam>
/// <param name="path">The path, which is name of the property that holds the id of the object to include.</param>
/// <returns></returns>
IDocumentQueryCustomization Include<TResult>(Expression<Func<TResult, object>> path);
/// <summary>
/// Includes the specified path in the query, loading the document specified in that path
/// </summary>
/// <typeparam name="TResult">The type of the object that holds the id that you want to include.</typeparam>
/// <typeparam name="TInclude">The type of the object that you want to include.</typeparam>
/// <param name="path">The path, which is name of the property that holds the id of the object to include.</param>
/// <returns></returns>
IDocumentQueryCustomization Include<TResult, TInclude>(Expression<Func<TResult, object>> path);
/// <summary>
/// Includes the specified path in the query, loading the document specified in that path
/// </summary>
/// <param name="path">The path.</param>
IDocumentQueryCustomization Include(string path);
/// <summary>
/// EXPERT ONLY: Instructs the query to wait for non stale results for the specified wait timeout.
/// This shouldn't be used outside of unit tests unless you are well aware of the implications
/// </summary>
/// <param name="waitTimeout">The wait timeout.</param>
IDocumentQueryCustomization WaitForNonStaleResults(TimeSpan waitTimeout);
/// <summary>
/// Filter matches to be inside the specified radius
/// </summary>
IDocumentQueryCustomization WithinRadiusOf(double radius, double latitude, double longitude, SpatialUnits radiusUnits = SpatialUnits.Kilometers);
/// <summary>
/// Filter matches to be inside the specified radius
/// </summary>
IDocumentQueryCustomization WithinRadiusOf(string fieldName, double radius, double latitude, double longitude, SpatialUnits radiusUnits = SpatialUnits.Kilometers);
/// <summary>
/// Filter matches based on a given shape - only documents with the shape defined in fieldName that
/// have a relation rel with the given shapeWKT will be returned
/// </summary>
/// <param name="fieldName">The name of the field containing the shape to use for filtering</param>
/// <param name="shapeWKT">The query shape</param>
/// <param name="rel">Spatial relation to check</param>
/// <returns></returns>
IDocumentQueryCustomization RelatesToShape(string fieldName, string shapeWKT, SpatialRelation rel);
/// <summary>
/// When using spatial queries, instruct the query to sort by the distance from the origin point
/// </summary>
IDocumentQueryCustomization SortByDistance();
/// <summary>
/// Order the search results randomly
/// </summary>
IDocumentQueryCustomization RandomOrdering();
/// <summary>
/// Order the search results randomly using the specified seed
/// this is useful if you want to have repeatable random queries
/// </summary>
IDocumentQueryCustomization RandomOrdering(string seed);
/// <summary>
/// Allow you to modify the index query before it is executed
/// </summary>
IDocumentQueryCustomization BeforeQueryExecution(Action<IndexQuery> action);
/// <summary>
/// Execute the transformation function on the results of this query.
/// </summary>
IDocumentQueryCustomization TransformResults(Func<IndexQuery,IEnumerable<object>, IEnumerable<object>> resultsTransformer);
/// <summary>
/// Adds matches highlighting for the specified field.
/// </summary>
/// <remarks>
/// The specified field should be analysed and stored for highlighter to work.
/// For each match it creates a fragment that contains matched text surrounded by highlighter tags.
/// </remarks>
/// <param name="fieldName">The field name to highlight.</param>
/// <param name="fragmentLength">The fragment length.</param>
/// <param name="fragmentCount">The maximum number of fragments for the field.</param>
/// <param name="fragmentsField">The field in query results item to put highlightings into.</param>
IDocumentQueryCustomization Highlight(string fieldName, int fragmentLength, int fragmentCount, string fragmentsField);
/// <summary>
/// Adds matches highlighting for the specified field.
/// </summary>
/// <remarks>
/// The specified field should be analysed and stored for highlighter to work.
/// For each match it creates a fragment that contains matched text surrounded by highlighter tags.
/// </remarks>
/// <param name="fieldName">The field name to highlight.</param>
/// <param name="fragmentLength">The fragment length.</param>
/// <param name="fragmentCount">The maximum number of fragments for the field.</param>
/// <param name="highlightings">Field highlightings for all results.</param>
IDocumentQueryCustomization Highlight(string fieldName, int fragmentLength, int fragmentCount, out FieldHighlightings highlightings);
/// <summary>
/// Sets the tags to highlight matches with.
/// </summary>
/// <param name="preTag">Prefix tag.</param>
/// <param name="postTag">Postfix tag.</param>
IDocumentQueryCustomization SetHighlighterTags(string preTag, string postTag);
/// <summary>
/// Sets the tags to highlight matches with.
/// </summary>
/// <param name="preTags">Prefix tags.</param>
/// <param name="postTags">Postfix tags.</param>
IDocumentQueryCustomization SetHighlighterTags(string[] preTags, string[] postTags);
}
}