first reference SolrNet.dll Microsoft.Practices.ServiceLocation httpwebadapters can also download Solrnet package with NuGet in the. NET IDe//Clear Last Request (does not clear will cause duplicate request error)SolrNet.Startup.Container.Clear (); SolrNet.Startup.InitContainer (); //connecting the SOLR serverSolrNet.Startup.Init<Object_acceptanceformsolr> ("http://60.205.149.65:8983/solr/connection"); //define SOLRisolroperations<object_acceptanceformsolr> SOLR = servicelocator.current.getinstance<isolroperations< Object_acceptanceformsolr>>(); //establish a sort, condition.Queryoptions options =Newqueryoptions (); options. Rows= ;//number of data barsOptions. Start =;//start;//Start Item//Create a condition collectionlist<isolrquery> query =NewList<isolrquery>(); //Create a query condition (this can be a single condition check, or the name of a word-breaker configuration find the value contained in all columns of the field under the word breaker)varQTB =NewSolrquerybyfield ("Text_search", Text_search); //Add Conditionquery. ADD (QTB); //Create a time range instanceSolrquerybyrange<datetime> Qdaterange =NULL; //This is used to query the time range of the data definition (no special case value 0: Querying all data)//data within seven days if(Time = ="-7"){//The last two parameters, one is the start time, the other is the end timeQdaterange =NewSolrquerybyrange<datetime> ("CreateDate", DateTime.Now.AddDays (int. Parse (Time)), DateTime.MaxValue); } Else if(Time = ="0")//All Data{Qdaterange=NewSolrquerybyrange<datetime> ("CreateDate", Datetime.minvalue, DateTime.MaxValue);} Else//other{Qdaterange=NewSolrquerybyrange<datetime> ("CreateDate", DateTime.Today.AddMonths (int. Parse (Time)), DateTime.MaxValue); } query. ADD (Qdaterange); //a list of more worthy relationshipsList<ISolrQuery> depment =NewList<isolrquery>(); for(inti =0; I < list. Count; i++) {Depment.add (NewSolrquerybyfield ("Department", List[i].childid)); } //Create a relationship, whether or OR and varQarea =NewSolrmultiplecriteriaquery (Depment,"OR"); //Add to Condition collectionquery. ADD (Qarea); //This can be omitted (there are multiple arrays in the array to determine the relationship of the array relationship to the array within the array)Solrquerybyrange<DateTime> Qdaterange =NULL; Qdaterange=NewSolrquerybyrange<datetime> ("CreateDate", Datetime.minvalue, DateTime.MaxValue); Query. ADD (Qdaterange); if(Obj.filter! =NULL&& Obj.filter.filters! =NULL&& Obj.filter.filters.Count >0) {List<ISolrQuery> filter =NewList<isolrquery>(); for(inti =0; i < Obj.filter.filters.Count; i++) { if(Obj.filter.filters[i].filters! =NULL&& obj.filter.filters[i].filters. Count >0) {List<ISolrQuery> Filtersli =NewList<isolrquery>(); for(intn =0; N < obj.filter.filters[i].filters. Count; n++) {Filtersli. ADD (NewSolrquerybyfield (Obj.filter.filters[i].filters[n].field, Obj.filter.filters[i].filters[n].value)); } //Create a relationship, whether or OR and varQareds =Newsolrmultiplecriteriaquery (Filtersli, obj.filter.filters[i].logic); query. ADD (qareds); } Else { if(Obj.filter.filters[i].field! =NULL&&!string. IsNullOrEmpty (Obj.filter.filters[i].field)) {List<ISolrQuery> Filtersli =NewList<isolrquery>(); Filtersli. ADD (NewSolrquerybyfield (Obj.filter.filters[i].field, Obj.filter.filters[i].value)); //Create a relationship, whether or OR and varqared =Newsolrmultiplecriteriaquery (Filtersli, Obj.filter.logic); query. ADD (qared); } } } } //Sortoptions. AddOrder (NewSolrnet.sortorder (Obj.sort[i].field, ORDER.ASC)); //relationship between conditional setsvarQtbo =NewSolrmultiplecriteriaquery (Query," and"); //executing the query, there are 5 overloads (the default Wt=json in Solr solrconfig), which always reports XML when fetching data: the first column of the first row has been tested I modified the configuration in Solrconfig wt=xmlsolrqueryresults<object_acceptanceformsolr> results =SOLR. Query (Qtbo, Options); It is important to note that the case must be the same with SOLR in the request data, as in the Solr file//For specific SOLR configurations, seehttp://www.cnblogs.com/wenxinghaha/p/3988375.html
Solr. Net-side (Solrnet)