Solr and Dotnet

17 views
Skip to first unread message

nilaani kanagaraj

unread,
Mar 25, 2021, 7:28:35 AM3/25/21
to SolrNet
Am writing a dot net code to get data from solr in json format.
*//dotnet code //*

[HttpGet]
        
         public IEnumerable<Employee> Get(string First_Name)

        {
            SolrNet.Startup.Init<Employee>("http://localhost:8983/solr/Sample");
            ISolrOperations<Employee> _solr = ServiceLocator.Current.GetInstance < ISolrOperations<Employee>>();
            string strQuery = ("First_Name:"+ "*");
            var query = new SolrQuery(strQuery);
            SortOrder sortOrder = new SortOrder("First_Name");
            var solrQueryResult = _solr.Query(query, new QueryOptions
            {
                Rows = 100, //Max Rows returned
                Start = 0,
                OrderBy = new[] { sortOrder },
                Fields = new[] { "Emp_ID" }
            });
            var list = solrQueryResult.ToList();

            return list;

        }
    }
}
    
Now am getting all the employee ids .what should i do if want to get employee id of particular First_Name. Let me know if any changes to be chnaged  in localhost url. I have attached the screenshot below. If anyone knows kindly help me.

Regards


solr.png
Reply all
Reply to author
Forward
0 new messages