コード例 #1
0
        /// <summary>
        /// Executes the SOLR delta import for specified collection.
        /// </summary>
        /// <param name="connection">Connection that specify collection to update.</param>
        /// <returns>Result of the operation.</returns>
        public string Execute(ISolrConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            return connection.Post("/dataimport?command=delta-import", string.Empty);
        }
コード例 #2
0
ファイル: OptimizeCommand.cs プロジェクト: osdezwart/SolrNet
 /// <summary>
 /// Executes this command
 /// </summary>
 /// <param name="connection"></param>
 /// <returns></returns>
 public string Execute(ISolrConnection connection)
 {
     var xml = new XmlDocument();
     var node = xml.CreateElement("optimize");
     foreach (var p in new[] {new KeyValuePair<bool?, string>(WaitSearcher, "waitSearcher"), new KeyValuePair<bool?, string>(WaitFlush, "waitFlush")}) {
         if (p.Key.HasValue) {
             var att = xml.CreateAttribute(p.Value);
             att.InnerText = p.Key.Value.ToString().ToLower();
             node.Attributes.Append(att);
         }
     }
     return connection.Post("/update", node.OuterXml);
 }
コード例 #3
0
ファイル: DeleteCommand.cs プロジェクト: osdezwart/SolrNet
 public string Execute(ISolrConnection connection)
 {
     var xml = new XmlDocument();
     var deleteNode = xml.CreateElement("delete");
     foreach (var p in new[] {new KeyValuePair<bool?, string>(FromPending, "fromPending"), new KeyValuePair<bool?, string>(FromCommitted, "fromCommitted")}) {
         if (p.Key.HasValue) {
             var att = xml.CreateAttribute(p.Value);
             att.InnerText = p.Key.Value.ToString().ToLower();
             deleteNode.Attributes.Append(att);
         }
     }
     deleteNode.InnerXml = Func.Join(Func.Select(deleteParam.ToXmlNode(), n => n.OuterXml));
     return connection.Post("/update", deleteNode.OuterXml);
 }
コード例 #4
0
		public string Execute(ISolrConnection connection) {
			var deleteNode = new XElement("delete");
            if (parameters != null) {
                if (parameters.CommitWithin.HasValue) {
                    var attr = new XAttribute("commitWithin", parameters.CommitWithin.Value.ToString(CultureInfo.InvariantCulture));
                    deleteNode.Add(attr);
                }
            }
		    var param = new[] {
		        KV.Create(FromPending, "fromPending"), 
                KV.Create(FromCommitted, "fromCommitted")
		    };
		    foreach (var p in param) {
				if (p.Key.HasValue) {
                    var att = new XAttribute(p.Value, p.Key.Value.ToString().ToLower());
					deleteNode.Add(att);
				}
			}
            deleteNode.Add(deleteParam.ToXmlNode().ToArray());
			return connection.Post("/update", deleteNode.ToString(SaveOptions.DisableFormatting));
		}
コード例 #5
0
ファイル: CommitCommand.cs プロジェクト: Jo1nes/SolrNet
		public string Execute(ISolrConnection connection) {
			var node = new XElement("commit");

		    var keyValuePairs = new[] {
		        new KeyValuePair<bool?, string>(WaitSearcher, "waitSearcher"), 
                new KeyValuePair<bool?, string>(WaitFlush, "waitFlush"), 
                new KeyValuePair<bool?, string>(ExpungeDeletes, "expungeDeletes")
		    };

		    foreach (var p in keyValuePairs) {
                if (!p.Key.HasValue) 
                    continue;

                var att = new XAttribute(p.Value, p.Key.Value.ToString().ToLower());
                node.Add(att);
            }

            if (MaxSegments.HasValue) {
                var att = new XAttribute("maxSegments", MaxSegments.ToString());
                node.Add(att);
            }

			return connection.Post("/update", node.ToString(SaveOptions.DisableFormatting));
		}
コード例 #6
0
ファイル: CommitCommand.cs プロジェクト: Cort01/SolrNet
        public string Execute(ISolrConnection connection)
        {
            var xml = new XmlDocument();
            var node = xml.CreateElement("commit");

            foreach (var p in new[] { new KeyValuePair<bool?, string>(WaitSearcher, "waitSearcher"), new KeyValuePair<bool?, string>(WaitFlush, "waitFlush"), new KeyValuePair<bool?, string>(ExpungeDeletes, "expungeDeletes") })
            {
                if (!p.Key.HasValue) continue;

                var att = xml.CreateAttribute(p.Value);
                att.InnerText = p.Key.Value.ToString().ToLower();
                node.Attributes.Append(att);
            }

            if (MaxSegments.HasValue)
            {
                var att = xml.CreateAttribute("maxSegments");
                att.InnerText = MaxSegments.ToString();
                node.Attributes.Append(att);
            }

            return connection.Post("/update", node.OuterXml);
        }
コード例 #7
0
 public string Execute(ISolrConnection connection)
 {
     var xml = new XmlDocument();
     var deleteNode = xml.CreateElement("delete");
     if (parameters != null) {
         if (parameters.CommitWithin.HasValue) {
             var attr = xml.CreateAttribute("commitWithin");
             attr.Value = parameters.CommitWithin.Value.ToString(CultureInfo.InvariantCulture);
             deleteNode.Attributes.Append(attr);
         }
     }
     var param = new[] {
         KV.Create(FromPending, "fromPending"),
         KV.Create(FromCommitted, "fromCommitted")
     };
     foreach (var p in param) {
         if (p.Key.HasValue) {
             var att = xml.CreateAttribute(p.Value);
             att.InnerText = p.Key.Value.ToString().ToLower();
             deleteNode.Attributes.Append(att);
         }
     }
     deleteNode.InnerXml = string.Join("", deleteParam.ToXmlNode().Select(n => n.OuterXml).ToArray());
     return connection.Post("/update", deleteNode.OuterXml);
 }
コード例 #8
0
ファイル: RollbackCommand.cs プロジェクト: osdezwart/SolrNet
 public string Execute(ISolrConnection connection)
 {
     return connection.Post("/update", "<rollback/>");
 }
コード例 #9
0
 public string Post(string relativeUrl, string s)
 {
     logger.DebugFormat("POSTing '{0}' to '{1}'", s, relativeUrl);
     return(connection.Post(relativeUrl, s));
 }
コード例 #10
0
 public async Task <string> Post(string relativeUrl, string s)
 {
     return(await conn.Post(relativeUrl, s));
 }
コード例 #11
0
        public string Execute(ISolrConnection connection)
        {
            string xml = GetDeleteXml();

            return(connection.Post("/update", xml));
        }
コード例 #12
0
ファイル: LoggingConnection.cs プロジェクト: evenbing/SolrNet
 public string Post(string relativeUrl, string s)
 {
     Console.WriteLine("Posting {0}", s);
     return(conn.Post(relativeUrl, s));
 }