Posts

Showing posts from May, 2015

select element after split in c#

string yourstring = "1:2:3";                                                                                                                        yourstring .Split(':').AsEnumerable().ElementAt(1);                                                                                output : 2 

post json to solr in C# using HttpPost

                string path = "http://localhost:8080/solr/collection1/update/json?commit=true";                 var httpWebRequest = (HttpWebRequest)WebRequest.Create(path);                 httpWebRequest.ContentType = "application/json";                 httpWebRequest.Method = "POST";                 using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))                 {                     string json = "[{\"id\":\"5\", \"title\":\"Testing JsonSolr\"}]";                     streamWriter.Write(json);                     streamWriter.Flush();       ...

Remove last char of string c#

YourString = YourString . Remove ( YourString . Length - 1 );

SolrNet error message : Object of type 'System.Collections.ArrayList' cannot be converted to type 'System.String'.

Consider SorlSearchResult as your class public class SolrSearchResult     {         [SolrUniqueKey("id")]         public string Id { get; set; }                  [SolrField("title")]         public string title { get; set; }         [SolrField("author")]         public string author { get; set; }     } Your issue is that the  title   field in your  SorlSearchResult  class is defined as a string, yet in solr schema.xml you have defined the title field as  multiValued="true"  which allows for multiple entries in the solr document and is shown in your solr return value.  <field name="title" type="text_general" indexed="true" stored="true" multiValued="true"/>                     The error message is...