public SolrSchema GetSchema(string schemaFileName) { string schemaXml = connection.Get("/admin/file", new[] { new KeyValuePair <string, string>("file", schemaFileName) }); var schema = XDocument.Parse(schemaXml); return(schemaParser.Parse(schema)); }
public ResponseHeader SendAndParseHeader(string handler, IEnumerable <KeyValuePair <string, string> > solrParams) { var r = connection.Get(handler, solrParams); var xml = XDocument.Parse(r); return(headerParser.Parse(xml)); }
/// <summary> /// Executes the query and returns results /// </summary> /// <returns>query results</returns> public SolrQueryResults <T> Execute(ISolrQuery q, QueryOptions options) { var param = GetAllParameters(q, options); var r = connection.Get(Handler, param); var qr = resultParser.Parse(r); return(qr); }
/// <summary> /// Executes the query and returns results /// </summary> /// <returns>query results</returns> public SolrQueryResults <T> Execute(ISolrQuery q, QueryOptions options) { var param = GetAllParameters(q, options); var results = new SolrQueryResults <T>(); var r = connection.Get(Handler, param); var xml = XDocument.Parse(r); resultParser.Parse(xml, results); return(results); }
public string Get(string relativeUrl, IEnumerable <KeyValuePair <string, string> > parameters) { var stringParams = string.Join(", ", parameters.Select(p => string.Format("{0}={1}", p.Key, p.Value)).ToArray()); logger.DebugFormat("GETting '{0}' from '{1}'", stringParams, relativeUrl); return(connection.Get(relativeUrl, parameters)); }
public SolrDIHStatus GetDIHStatus(KeyValuePair <string, string> options) { var response = connection.Get("/dataimport", null); var dihstatus = XDocument.Parse(response); return(dihStatusParser.Parse(dihstatus)); }
/// <summary> /// Executes the query and returns results /// </summary> /// <returns>query results</returns> public ISolrQueryResults <T> Execute(ISolrQuery q, QueryOptions options) { var param = GetAllParameters(q, options); string r = connection.Get("/select", param); var qr = resultParser.Parse(r); return(qr); }
public string Get(string relativeUrl, IEnumerable <KeyValuePair <string, string> > parameters) { var keyValuePairs = parameters.ToList(); var array = keyValuePairs.Select(x => String.Format("{0}={1}", x.Key, x.Value)).ToArray(); Debug.WriteLine("GET '{0}' from '{1}'", String.Join(", ", array), relativeUrl); return(connection.Get(relativeUrl, keyValuePairs)); }
public string Get(string relativeUrl, IEnumerable <KeyValuePair <string, string> > parameters) { Console.WriteLine("Getting"); var r = conn.Get(relativeUrl, parameters); Console.WriteLine("Result is:\n" + r); return(r); }
public void TestCache(ISolrConnection conn) { foreach (var i in Enumerable.Range(0, 1000)) { conn.Get("/select/", new Dictionary <string, string> { { "q", "*:*" }, }); } }
/// <summary> /// Executes the query and returns results /// </summary> /// <returns>query results</returns> public new CrownPeakQueryResults <T> Execute(ISolrQuery q, SolrNet.Commands.Parameters.QueryOptions options) { var param = GetAllParameters(q, options); var results = new CrownPeakQueryResults <T>(); var r = _connection.Get(Handler, param); var xml = XDocument.Parse(r); _parser.Parse(xml, results); return(results); }
public string AutoComplete(string input) { var results = connection.Get("/autosuggest", new Dictionary <string, string> { { "q", input } }); const string suggestionsStart = "\"suggestion\":"; var startIndex = results.IndexOf(suggestionsStart) + suggestionsStart.Length; return(results.Substring(startIndex, results.IndexOf("]}") - startIndex + 1)); }
public string Execute(ISolrConnection connection) { return(connection.Get("/admin/ping", new Dictionary <string, string>())); }
public void TestCache(ISolrConnection conn) { foreach (var i in Enumerable.Range(0, 1000)) { conn.Get("/select/", new Dictionary<string, string> { {"q", "*:*"}, }); } }
/// <summary> /// Executes a Core command /// </summary> /// <param name="connection">The SolrConnection to use.</param> /// <returns>The results of the Command.</returns> public string Execute(ISolrConnection connection) { return(connection.Get("/admin/cores", Parameters.ToArray())); }
/// <summary> /// Executes a Replication command /// </summary> /// <param name="connection">The SolrConnection to use.</param> /// <returns>The results of the Command.</returns> public string Execute(ISolrConnection connection) { return(connection.Get("/replication", Parameters.ToArray())); }
/// <summary> /// Executes a Core command /// </summary> /// <param name="connection">The SolrConnection to use.</param> /// <returns>The results of the Command.</returns> public async Task <string> Execute(ISolrConnection connection) { return(await connection.Get("/admin/cores", Parameters.ToArray())); }
/// <summary> /// Executes the query and returns results /// </summary> /// <returns>query results</returns> public async Task <SolrQueryResults <T> > Execute(ISolrQuery q, QueryOptions options) { var param = GetAllParameters(q, options); var results = new SolrQueryResults <T>(); string json = await connection.Get(Handler, param); if (json == null) { return(results); } var rootProduct = JsonConvert.DeserializeObject <SolrResponse <T> >(json); JObject obj = JObject.Parse(json); Dictionary <string, object> dictionnaryProperties = new Dictionary <string, object>(); PropertyInfo[] myPropertyInfo; myPropertyInfo = Type.GetType(typeof(T).AssemblyQualifiedName).GetProperties(); for (int i = 0; i < myPropertyInfo.Length; i++) { dictionnaryProperties = myPropertyInfo[i].GetPropertyAttributes(dictionnaryProperties); } for (int i = 0; i < rootProduct.Response.NumFound; i++) { foreach (var item in obj["response"]["docs"][i]) { var attribute = dictionnaryProperties.Where(x => item.ToString().Contains(x.Key)).FirstOrDefault(); if (!string.IsNullOrEmpty(attribute.Key)) { PropertyInfo pInfo = attribute.Value as PropertyInfo; bool stringSingle = pInfo.PropertyType.IsAssignableFrom(typeof(Dictionary <String, Single>)); bool stringString = pInfo.PropertyType.IsAssignableFrom(typeof(Dictionary <String, String>)); bool stringInt = pInfo.PropertyType.IsAssignableFrom(typeof(Dictionary <String, Int32>)); if (stringSingle) { var dico = pInfo.GetValue(rootProduct.Response.Data[i], null) as Dictionary <string, Single>; if (dico == null) { dico = new Dictionary <string, Single>(); } foreach (var value in item.ToList()) { string name = (item as JProperty).Name.Remove(0, attribute.Key.Length); dico.Add(name, Single.Parse(value.ToString())); } pInfo.SetValue(rootProduct.Response.Data[i], dico, null); } if (stringString) { var dico = pInfo.GetValue(rootProduct.Response.Data[i], null) as Dictionary <string, string>; if (dico == null) { dico = new Dictionary <string, string>(); } foreach (var value in item.ToList()) { string name = (item as JProperty).Name.Remove(0, attribute.Key.Length); dico.Add(name, value.ToString()); } pInfo.SetValue(rootProduct.Response.Data[i], dico, null); } if (stringInt) { var dico = pInfo.GetValue(rootProduct.Response.Data[i], null) as Dictionary <string, int>; if (dico == null) { dico = new Dictionary <string, int>(); } foreach (var value in item.ToList()) { string name = (item as JProperty).Name.Remove(0, attribute.Key.Length); dico.Add(name, int.Parse(value.ToString())); } pInfo.SetValue(rootProduct.Response.Data[i], dico, null); } } } results.Add(rootProduct.Response.Data[i]); } //Facet Names if (rootProduct.Facets != null) { foreach (var item in rootProduct.Facets.FacetFields) { var jsonItem = (from j in obj["facet_counts"]["facet_fields"] where j.Path.Contains(item.Key) select j).First(); if (jsonItem != null) { item.Value.Clear(); var jsonArray = jsonItem.First(); if (jsonArray != null) { var array = jsonArray.ToList(); for (int i = 0; i < array.Count; i = i + 2) { int value = int.Parse(array[i + 1].ToString()); string key = array[i].ToString(); item.Value.Add(new KeyValuePair <string, int>(key, value)); } } } } results.FacetFields = rootProduct.Facets.FacetFields; } return(results); }
/// <summary> /// Executes a Replication command /// </summary> /// <param name="connection">The SolrConnection to use.</param> /// <returns>The results of the Command.</returns> public string Execute(ISolrConnection connection) { return connection.Get("/replication", Parameters.ToArray()); }
public string Get(string relativeUrl, IEnumerable <KeyValuePair <string, string> > parameters) { // TODO add other args Log($"{nameof(relativeUrl)}={relativeUrl}"); return(_connection.Get(relativeUrl, parameters)); }
/// <summary> /// Executes a Core command /// </summary> /// <param name="connection">The SolrConnection to use.</param> /// <returns>The results of the Command.</returns> public string Execute(ISolrConnection connection) { return connection.Get("/admin/cores", Parameters.ToArray()); }
public string Execute(ISolrConnection connection) { return connection.Get("/admin/ping", new Dictionary<string, string>()); }
/// <summary> /// Gets the raw Solr schema /// </summary> /// <param name="connection"></param> /// <returns></returns> public string Execute(ISolrConnection connection) { return connection.Get("/admin/file", new[] {new KeyValuePair<string, string>("file", "schema.xml")}); }
/// <summary> /// Gets the raw Solr schema /// </summary> /// <param name="connection"></param> /// <returns></returns> public string Execute(ISolrConnection connection) { return(connection.Get("/admin/file", new[] { new KeyValuePair <string, string>("file", "schema.xml") })); }