本文整理汇总了C#中IndexQuery类的典型用法代码示例。如果您正苦于以下问题:C# IndexQuery类的具体用法?C# IndexQuery怎么用?C# IndexQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndexQuery类属于命名空间,在下文中一共展示了IndexQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:kblooie,项目名称:ravendb,代码行数:30,代码来源:HttpContextExtensions.cs
示例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;
}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:DynamicQueryExtensions.cs
示例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);
}
}
开发者ID:nzdunic,项目名称:ravendb,代码行数:31,代码来源:DynamicQueryRunner.cs
示例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;
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:26,代码来源:QueryActions.cs
示例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;
}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:DynamicQueryExtensions.cs
示例6: ExecutingQueryInfo
public ExecutingQueryInfo(DateTime startTime, IndexQuery queryInfo, long queryId, CancellationTokenSource tokenSource)
{
StartTime = startTime;
QueryInfo = queryInfo;
QueryId = queryId;
stopwatch = Stopwatch.StartNew();
TokenSource = tokenSource;
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:8,代码来源:ExecutingQueryInfo.cs
示例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 };
});
}
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs
示例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 };
});
}
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs
示例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 };
});
}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs
示例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 };
});
}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:8,代码来源:DatabaseBulkOperations.cs
示例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));
}
开发者ID:nicolastarzia,项目名称:allReady,代码行数:11,代码来源:CampaignController.cs
示例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;
}
}
开发者ID:samueldjack,项目名称:ravendb,代码行数:10,代码来源:DynamicQueryRunner.cs
示例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;
}
开发者ID:IdanHaim,项目名称:ravendb,代码行数:55,代码来源:DynamicQueryRunner.cs
示例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);
}
开发者ID:robashton,项目名称:ravendb,代码行数:11,代码来源:IndexQueryUrl.cs
示例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);
}
开发者ID:robashton,项目名称:ravendb,代码行数:11,代码来源:IndexQueryUrl.cs
示例16: can_encode_and_decode_IndexQuery_Query_pound
public void can_encode_and_decode_IndexQuery_Query_pound()
{
var expected = Some.String() + '#' + Some.String();
var indexQuery = new IndexQuery();
indexQuery.Query = expected;
IndexQuery result = EncodeAndDecodeIndexQuery(indexQuery);
Assert.Equal(expected, result.Query);
}
开发者ID:robashton,项目名称:ravendb,代码行数:12,代码来源:IndexQueryUrl.cs
示例17: QueryDocumentIds
public IEnumerable<string> QueryDocumentIds(string index, IndexQuery query, CancellationTokenSource tokenSource, out bool stale)
{
var queryStat = AddToCurrentlyRunningQueryList(index, query, tokenSource);
try
{
bool isStale = false;
HashSet<string> loadedIds = null;
TransactionalStorage.Batch(
actions =>
{
var definition = IndexDefinitionStorage.GetIndexDefinition(index);
if (definition == null)
throw new ArgumentException("specified index definition was not found", "index");
isStale = actions.Staleness.IsIndexStale(definition.IndexId, query.Cutoff, null);
if (isStale == false && query.Cutoff == null)
{
var indexInstance = Database.IndexStorage.GetIndexInstance(index);
isStale = isStale || (indexInstance != null && indexInstance.IsMapIndexingInProgress);
}
if (isStale && actions.Staleness.IsIndexStaleByTask(definition.IndexId, query.Cutoff) == false &&
actions.Staleness.IsReduceStale(definition.IndexId) == false)
{
var viewGenerator = IndexDefinitionStorage.GetViewGenerator(index);
if (viewGenerator == null)
throw new ArgumentException("specified index definition was not found", "index");
var forEntityNames = viewGenerator.ForEntityNames.ToList();
var lastIndexedEtag = actions.Indexing.GetIndexStats(definition.IndexId).LastIndexedEtag;
if (Database.LastCollectionEtags.HasEtagGreaterThan(forEntityNames, lastIndexedEtag) == false)
isStale = false;
}
var indexFailureInformation = actions.Indexing.GetFailureRate(definition.IndexId);
if (indexFailureInformation.IsInvalidIndex)
{
throw new IndexDisabledException(indexFailureInformation);
}
loadedIds = new HashSet<string>(from queryResult in Database.IndexStorage.Query(index, query, result => true, new FieldsToFetch(null, false, Constants.DocumentIdFieldName), Database.IndexQueryTriggers, tokenSource.Token)
select queryResult.Key);
});
stale = isStale;
return loadedIds;
}
finally
{
RemoveFromCurrentlyRunningQueryList(index, queryStat);
}
}
开发者ID:jrusbatch,项目名称:ravendb,代码行数:53,代码来源:QueryActions.cs
示例18: PerformBulkOperation
private RavenJArray PerformBulkOperation(string index, IndexQuery indexQuery, bool allowStale, Func<string, TransactionInformation, object> batchOperation)
{
var array = new RavenJArray();
var bulkIndexQuery = new IndexQuery
{
Query = indexQuery.Query,
Start = indexQuery.Start,
Cutoff = indexQuery.Cutoff,
WaitForNonStaleResultsAsOfNow = indexQuery.WaitForNonStaleResultsAsOfNow,
PageSize = int.MaxValue,
FieldsToFetch = new[] { Constants.DocumentIdFieldName },
SortedFields = indexQuery.SortedFields,
HighlighterPreTags = indexQuery.HighlighterPreTags,
HighlighterPostTags = indexQuery.HighlighterPostTags,
HighlightedFields = indexQuery.HighlightedFields,
SortHints = indexQuery.SortHints
};
bool stale;
var queryResults = database.Queries.QueryDocumentIds(index, bulkIndexQuery, tokenSource, out stale);
if (stale && allowStale == false)
{
throw new InvalidOperationException(
"Bulk operation cancelled because the index is stale and allowStale is false");
}
var token = tokenSource.Token;
const int batchSize = 1024;
using (var enumerator = queryResults.GetEnumerator())
{
while (true)
{
if (timeout != null)
timeout.Delay();
var batchCount = 0;
token.ThrowIfCancellationRequested();
database.TransactionalStorage.Batch(actions =>
{
while (batchCount < batchSize && enumerator.MoveNext())
{
batchCount++;
var result = batchOperation(enumerator.Current, transactionInformation);
array.Add(RavenJObject.FromObject(result));
}
});
if (batchCount < batchSize) break;
}
}
return array;
}
开发者ID:cocytus,项目名称:ravendb,代码行数:52,代码来源:DatabaseBulkOperations.cs
示例19: ExecuteDynamicQuery
public QueryResult ExecuteDynamicQuery(string entityName, IndexQuery query)
{
// Create the map
var map = DynamicQueryMapping.Create(documentDatabase, query, entityName);
var touchTemporaryIndexResult = GetAppropriateIndexToQuery(entityName, query, map);
map.IndexName = touchTemporaryIndexResult.Item1;
// Re-write the query
string realQuery = map.Items.Aggregate(query.Query,
(current, mapItem) => current.Replace(mapItem.QueryFrom, mapItem.To));
return ExecuteActualQuery(query, map, touchTemporaryIndexResult, realQuery);
}
开发者ID:nzdunic,项目名称:ravendb,代码行数:14,代码来源:DynamicQueryRunner.cs
示例20: GetAppropriateIndexToQuery
private Tuple<string, bool> GetAppropriateIndexToQuery(string entityName, IndexQuery query, DynamicQueryMapping map)
{
var appropriateIndex = new DynamicQueryOptimizer(documentDatabase).SelectAppropriateIndex(entityName, query);
if (appropriateIndex != null)
{
if (appropriateIndex.StartsWith("Temp/"))// temporary index, we need to increase its usage
{
return TouchTemporaryIndex(appropriateIndex, "Auto/" + appropriateIndex.Substring(5),
() => documentDatabase.IndexDefinitionStorage.GetIndexDefinition(appropriateIndex));
}
return Tuple.Create(appropriateIndex, false);
}
return TouchTemporaryIndex(map.TemporaryIndexName, map.PermanentIndexName,
map.CreateIndexDefinition);
}
开发者ID:nzdunic,项目名称:ravendb,代码行数:15,代码来源:DynamicQueryRunner.cs
注:本文中的IndexQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论