本文整理汇总了C#中IndexQuery类的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery类的具体用法?C# IndexQuery怎么用?C# IndexQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexQuery类属于命名空间,在下文中一共展示了IndexQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIndexQueryFromHttpContext
public static IndexQuery GetIndexQueryFromHttpContext(this IHttpContext context, int maxPageSize)
{
var query = new IndexQuery
{
Query = context.Request.QueryString["query"] ?? "",
Start = context.GetStart(),
Cutoff = context.GetCutOff(),
PageSize = context.GetPageSize(maxPageSize),
SkipTransformResults = context.GetSkipTransformResults(),
FieldsToFetch = context.Request.QueryString.GetValues("fetch"),
GroupBy = context.Request.QueryString.GetValues("groupBy"),
AggregationOperation = context.GetAggregationOperation(),
SortedFields = context.Request.QueryString.GetValues("sort")
.EmptyIfNull()
.Select(x => new SortedField(x))
.ToArray()
};
double lat = context.GetLat(), lng = context.GetLng(), radius = context.GetRadius();
if (lat != 0 || lng != 0 || radius != 0)
{
return new SpatialIndexQuery(query)
{
Latitude = lat,
Longitude = lng,
Radius = radius,
};
}
return query;
}
示例2: FindDynamicIndexName
public static string FindDynamicIndexName(this DocumentDatabase self, string entityName, IndexQuery query)
{
var result = new DynamicQueryOptimizer(self).SelectAppropriateIndex(entityName, query.Clone());
if (result.MatchType == DynamicQueryMatchType.Complete)
return result.IndexName;
return null;
}
示例3: ExecuteActualQuery
private QueryResult ExecuteActualQuery(IndexQuery query, DynamicQueryMapping map, Tuple<string, bool> touchTemporaryIndexResult, string realQuery)
{
// Perform the query until we have some results at least
QueryResult result;
var sp = Stopwatch.StartNew();
while (true)
{
result = documentDatabase.Query(map.IndexName,
new IndexQuery
{
Cutoff = query.Cutoff,
PageSize = query.PageSize,
Query = realQuery,
Start = query.Start,
FieldsToFetch = query.FieldsToFetch,
GroupBy = query.GroupBy,
AggregationOperation = query.AggregationOperation,
SortedFields = query.SortedFields,
});
if (!touchTemporaryIndexResult.Item2 ||
!result.IsStale ||
result.Results.Count >= query.PageSize ||
sp.Elapsed.TotalSeconds > 15)
{
return result;
}
Thread.Sleep(100);
}
}
示例4: Query
public QueryResultWithIncludes Query(string index, IndexQuery query, CancellationToken externalCancellationToken)
{
QueryResultWithIncludes result = null;
using (var cts = CancellationTokenSource.CreateLinkedTokenSource(externalCancellationToken, WorkContext.CancellationToken))
{
var cancellationToken = cts.Token;
TransactionalStorage.Batch(
accessor =>
{
using (var op = new DatabaseQueryOperation(Database, index, query, accessor, cancellationToken)
{
ShouldSkipDuplicateChecking = query.SkipDuplicateChecking
})
{
var list = new List<RavenJObject>();
op.Init();
op.Execute(list.Add);
op.Result.Results = list;
result = op.Result;
}
});
}
return result;
}
示例5: ExplainDynamicIndexSelection
public static List<DynamicQueryOptimizer.Explanation> ExplainDynamicIndexSelection(this DocumentDatabase self, string entityName, IndexQuery query)
{
var explanations = new List<DynamicQueryOptimizer.Explanation>();
new DynamicQueryOptimizer(self)
.SelectAppropriateIndex(entityName, query.Clone(), explanations);
return explanations;
}
示例6: ExecutingQueryInfo
public ExecutingQueryInfo(DateTime startTime, IndexQuery queryInfo, long queryId, CancellationTokenSource tokenSource)
{
StartTime = startTime;
QueryInfo = queryInfo;
QueryId = queryId;
stopwatch = Stopwatch.StartNew();
TokenSource = tokenSource;
}
示例7: DeleteByIndex
public RavenJArray DeleteByIndex(string indexName, IndexQuery queryToDelete, bool allowStale)
{
return PerformBulkOperation(indexName, queryToDelete, allowStale, (docId, tx) =>
{
database.Delete(docId, null, tx);
return new { Document = docId, Deleted = true };
});
}
示例8: UpdateByIndex
public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, PatchRequest[] patchRequests, bool allowStale)
{
return PerformBulkOperation(indexName, queryToUpdate, allowStale, (docId, tx) =>
{
var patchResult = database.ApplyPatch(docId, null, patchRequests, tx);
return new { Document = docId, Result = patchResult };
});
}
示例9: DeleteByIndex
public RavenJArray DeleteByIndex(string indexName, IndexQuery queryToDelete, BulkOperationOptions options = null)
{
return PerformBulkOperation(indexName, queryToDelete, options, (docId, tx) =>
{
database.Documents.Delete(docId, null, tx);
return new { Document = docId, Deleted = true };
});
}
示例10: UpdateByIndex
public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, ScriptedPatchRequest patch, BulkOperationOptions options = null)
{
return PerformBulkOperation(indexName, queryToUpdate, options, (docId, tx) =>
{
var patchResult = database.Patches.ApplyPatch(docId, null, patch, tx);
return new { Document = docId, Result = patchResult.Item1, Debug = patchResult.Item2 };
});
}
示例11: Index
// GET: Campaign
public async Task<IActionResult> Index()
{
var query = new IndexQuery();
if (User.IsUserType(UserType.OrgAdmin))
{
query.OrganizationId = User.GetOrganizationId();
}
return View(await _mediator.SendAsync(query));
}
示例12: UpdateFieldNamesForSortedFields
private static void UpdateFieldNamesForSortedFields(IndexQuery query, DynamicQueryMapping map)
{
if (query.SortedFields == null) return;
foreach (var sortedField in query.SortedFields)
{
var item = map.Items.FirstOrDefault(x => x.From == sortedField.Field);
if (item != null)
sortedField.Field = item.To;
}
}
示例13: CreateIndexQuery
private static IndexQuery CreateIndexQuery(IndexQuery query, DynamicQueryMapping map, string realQuery)
{
var indexQuery = new IndexQuery
{
Cutoff = query.Cutoff,
WaitForNonStaleResultsAsOfNow = query.WaitForNonStaleResultsAsOfNow,
PageSize = query.PageSize,
Query = realQuery,
Start = query.Start,
FieldsToFetch = query.FieldsToFetch,
IsDistinct = query.IsDistinct,
SortedFields = query.SortedFields,
DefaultField = query.DefaultField,
CutoffEtag = query.CutoffEtag,
DebugOptionGetIndexEntries = query.DebugOptionGetIndexEntries,
DefaultOperator = query.DefaultOperator,
SkippedResults = query.SkippedResults,
HighlighterPreTags = query.HighlighterPreTags,
HighlighterPostTags = query.HighlighterPostTags,
HighlightedFields = query.HighlightedFields,
HighlighterKeyName = query.HighlighterKeyName,
ResultsTransformer = query.ResultsTransformer,
TransformerParameters = query.TransformerParameters,
ExplainScores = query.ExplainScores,
SortHints = query.SortHints,
ShowTimings = query.ShowTimings,
AllowMultipleIndexEntriesForSameDocumentToResultTransformer = query.AllowMultipleIndexEntriesForSameDocumentToResultTransformer,
DisableCaching = query.DisableCaching,
SkipDuplicateChecking = query.SkipDuplicateChecking,
WaitForNonStaleResults = query.WaitForNonStaleResults
};
if (indexQuery.SortedFields == null)
return indexQuery;
for (int index = 0; index < indexQuery.SortedFields.Length; index++)
{
var sortedField = indexQuery.SortedFields[index];
var fieldName = sortedField.Field;
bool hasRange = false;
if (fieldName.EndsWith("_Range"))
{
fieldName = fieldName.Substring(0, fieldName.Length - "_Range".Length);
hasRange = true;
}
var item = map.Items.FirstOrDefault(x => string.Equals(x.QueryFrom, fieldName, StringComparison.InvariantCultureIgnoreCase));
if (item == null)
continue;
indexQuery.SortedFields[index] = new SortedField(hasRange ? item.To + "_Range" : item.To);
indexQuery.SortedFields[index].Descending = sortedField.Descending;
}
return indexQuery;
}
示例14: can_encode_and_decode_IndexQuery_PageSize
public void can_encode_and_decode_IndexQuery_PageSize()
{
var expected = Some.Integer();
var indexQuery = new IndexQuery();
indexQuery.PageSize = expected;
IndexQuery result = EncodeAndDecodeIndexQuery(indexQuery);
Assert.Equal(expected, result.PageSize);
}
示例15: can_encode_and_decode_IndexQuery_Start
public void can_encode_and_decode_IndexQuery_Start()
{
int expected = Some.Integer();
var indexQuery = new IndexQuery();
indexQuery.Start = expected;
IndexQuery result = EncodeAndDecodeIndexQuery(indexQuery);
Assert.Equal(expected, result.Start);
}