Example #1
0
        public Task <IDeleteResponse> DeleteByQueryAsync(string query, DeleteByQueryParameters parameters = null)
        {
            var descriptor = new RoutingQueryPathDescriptor();
            var path       = this.PathResolver.GetPathForDynamic(descriptor, "_query");

            if (parameters != null)
            {
                path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPathAsync(path, query));
        }
        /// <summary>
        /// Deletes all documents that match the query, without specifying T the return documents is an IEnumerable<dynamic>
        /// </summary>
        /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param>
        /// <param name="parameters">Control routing/consistency and replication</param>
        /// <returns>IDeleteResponse, check .IsValid to validate success</returns>
        public Task <IDeleteResponse> DeleteByQueryAsync(Func <RoutingQueryPathDescriptor, BaseQuery> query, DeleteByQueryParameters parameters = null)
        {
            var descriptor  = new RoutingQueryPathDescriptor();
            var bq          = query(descriptor);
            var stringQuery = this.Serialize(bq);
            var path        = this.PathResolver.GetDeleteByQueryPathForDynamic(descriptor, "_query");

            if (parameters != null)
            {
                path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPathAsync(path, stringQuery));
        }
        /// <summary>
        /// Deletes all documents that match the query
        /// </summary>
        /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param>
        /// <param name="parameters">Control routing/consistency and replication</param>
        /// <returns>IDeleteResponse, check .IsValid to validate success</returns>
        public IDeleteResponse DeleteByQuery <T>(Func <RoutingQueryPathDescriptor <T>, BaseQuery> query, DeleteByQueryParameters parameters = null) where T : class
        {
            var descriptor  = new RoutingQueryPathDescriptor <T>();
            var bq          = query(descriptor);
            var stringQuery = this.Serialize(bq);
            var path        = this.PathResolver.GetPathForTyped(descriptor, "_query");

            if (parameters != null)
            {
                path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPath(path, stringQuery));
        }
Example #4
0
        public void FilteredQueryCombinesUsingStatic()
        {
            var s = new RoutingQueryPathDescriptor <ElasticSearchProject>()
                    .AllIndices()
                    .AllTypes()
                    .Filtered(fq =>
                              fq.Filter(ff =>
                                        Filter <ElasticSearchProject> .Term(f => f.Name, "foo") ||
                                        Filter <ElasticSearchProject> .Term(f => f.Name, "bar")
                                        )
                              );

            this.JsonEquals(s, System.Reflection.MethodInfo.GetCurrentMethod());
        }
Example #5
0
        public void FilteredQueryCombinesUsingStatic()
        {
            var s = new RoutingQueryPathDescriptor<ElasticSearchProject>()
              .AllIndices()
              .AllTypes()
              .Filtered(fq =>
                  fq.Filter(ff =>
                    Filter<ElasticSearchProject>.Term(f => f.Name, "foo")
                    || Filter<ElasticSearchProject>.Term(f => f.Name, "bar")
                  )
               );

            this.JsonEquals(s, System.Reflection.MethodInfo.GetCurrentMethod());
        }
Example #6
0
        /// <summary>
        /// Deletes all documents that match the query
        /// </summary>
        /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param>
        /// <param name="parameters">Control routing/consistency and replication</param>
        /// <returns>IDeleteResponse, check .IsValid to validate success</returns>
        public Task <IDeleteResponse> DeleteByQueryAsync <T>(Action <RoutingQueryPathDescriptor <T> > query, DeleteByQueryParameters parameters = null) where T : class
        {
            var descriptor = new RoutingQueryPathDescriptor <T>();

            query(descriptor);
            var stringQuery = this.Serialize(descriptor);
            var path        = this.PathResolver.GetPathForTyped(descriptor, "_query");

            if (parameters != null)
            {
                path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPathAsync(path, stringQuery));
        }
Example #7
0
        /// <summary>
        /// Deletes all documents that match the query, without specifying T the return documents is an IEnumerable<dynamic>
        /// </summary>
        /// <param name="query">RoutingQueryPathDescriptor also allows you to control which indices and types are affected</param>
        /// <param name="parameters">Control routing/consistency and replication</param>
        /// <returns>IDeleteResponse, check .IsValid to validate success</returns>
        public IDeleteResponse DeleteByQuery(Action <RoutingQueryPathDescriptor> query, DeleteByQueryParameters parameters = null)
        {
            var descriptor = new RoutingQueryPathDescriptor();

            query(descriptor);
            var stringQuery = this.Serialize(descriptor);
            var path        = this.PathResolver.GetPathForDynamic(descriptor, "_query");

            if (parameters != null)
            {
                path = this.PathResolver.AppendDeleteByQueryParametersToPath(path, parameters);
            }
            return(this._deleteToPath(path, stringQuery));
        }
Example #8
0
        /// <summary>
        /// Register a percolator
        /// </summary>
        /// <param name="name">Name of the percolator</param>
        /// <param name="querySelector">Path and query descriptor using T to describe the query</param>
        public IRegisterPercolateResponse RegisterPercolator <T>(string name, Action <QueryPathDescriptor <T> > querySelector) where T : class
        {
            querySelector.ThrowIfNull("queryDescriptor");
            var descriptor = new RoutingQueryPathDescriptor <T>();

            querySelector(descriptor);
            var query = this.Serialize(new { query = descriptor });
            var index = this.IndexNameResolver.GetIndexForType <T>();

            if (descriptor._Indices.HasAny())
            {
                index = descriptor._Indices.First();
            }
            var path = "_percolator/{0}/{1}".F(Uri.EscapeDataString(index), Uri.EscapeDataString(name));

            return(this._RegisterPercolator(path, query));
        }