public IEnumerable <IndexQueryResult> Query( string index, IndexQuery query, Func <IndexQueryResult, bool> shouldIncludeInResults, FieldsToFetch fieldsToFetch, OrderedPartCollection <AbstractIndexQueryTrigger> indexQueryTriggers) { Index value; if (indexes.TryGetValue(index, out value) == false) { log.Debug("Query on non existing index '{0}'", index); throw new InvalidOperationException("Index '" + index + "' does not exists"); } var indexQueryOperation = new Index.IndexQueryOperation(value, query, shouldIncludeInResults, fieldsToFetch, indexQueryTriggers); if (query.Query != null && query.Query.Contains(Constants.IntersectSeperator)) { return(indexQueryOperation.IntersectionQuery()); } return(indexQueryOperation.Query()); }
public IEnumerable<IndexQueryResult> Query(string index, IndexQuery query, Func<IndexQueryResult, bool> shouldIncludeInResults, FieldsToFetch fieldsToFetch, OrderedPartCollection<AbstractIndexQueryTrigger> indexQueryTriggers, CancellationToken token) { Index value = TryIndexByName(index); if (value == null) { log.Debug("Query on non existing index '{0}'", index); throw new InvalidOperationException("Index '" + index + "' does not exists"); } if ((value.Priority.HasFlag(IndexingPriority.Idle) || value.Priority.HasFlag(IndexingPriority.Abandoned)) && value.Priority.HasFlag(IndexingPriority.Forced) == false) { documentDatabase.TransactionalStorage.Batch(accessor => { value.Priority = IndexingPriority.Normal; try { accessor.Indexing.SetIndexPriority(value.indexId, IndexingPriority.Normal); } catch (Exception e) { if (accessor.IsWriteConflict(e) == false) throw; // we explciitly ignore write conflicts here, it is okay if we got set twice (two concurrent queries, or setting while indexing). } documentDatabase.WorkContext.ShouldNotifyAboutWork(() => "Idle index queried"); documentDatabase.Notifications.RaiseNotifications(new IndexChangeNotification() { Name = value.PublicName, Type = IndexChangeTypes.IndexPromotedFromIdle }); }); } var indexQueryOperation = new Index.IndexQueryOperation(value, query, shouldIncludeInResults, fieldsToFetch, indexQueryTriggers); if (query.Query != null && query.Query.Contains(Constants.IntersectSeparator)) return indexQueryOperation.IntersectionQuery(token); return indexQueryOperation.Query(token); }
public IEnumerable<IndexQueryResult> Query( string index, IndexQuery query, Func<IndexQueryResult, bool> shouldIncludeInResults, FieldsToFetch fieldsToFetch, OrderedPartCollection<AbstractIndexQueryTrigger> indexQueryTriggers) { Index value; if (indexes.TryGetValue(index, out value) == false) { log.Debug("Query on non existing index '{0}'", index); throw new InvalidOperationException("Index '" + index + "' does not exists"); } var indexQueryOperation = new Index.IndexQueryOperation(value, query, shouldIncludeInResults, fieldsToFetch, indexQueryTriggers); if (query.Query != null && query.Query.Contains(Constants.IntersectSeperator)) return indexQueryOperation.IntersectionQuery(); return indexQueryOperation.Query(); }