c# - Solrnet not finding SolrField attribute -


i trying integrate solrnet project working on , unable solrnet produce document populated poco. below example of pocos i'm using

public class person : icustominterface {     [solrfield("text")]     public string contactnumber { get; set; }      [solrfield("text")]     public string contactfax { get; set; }      [solrfield("text")]     public string contactemail { get; set; }     [solrfield("text")]     public string familyname { get; set; }     [solrfield("text")]     public string givenname { get; set; }     [solrfield("text")]     public string middlename { get; set; }     [solrfield("text")]     public string title { get; set; }     [solrfield("text")]     public string gender { get; set; }     [solrfield("text")]     public string placeofbirth { get; set; }     [solrfield("text")]     public string countryofbirth { get; set; }      [solruniquekey("id")]     public string id { get; set; } } 

i calling init function before try , index above using following code.

startup.init<person>("http://localhost:8080/solr-4.1.0"); 

i calling following try , index object.

var solr = servicelocator.current.getinstance<isolroperations<person>>(); solr.add(mypoco); solr.commit(); 

the error on 'solr.add(person)' is: "document missing mandatory uniquekey field: id". looking @ http request being sent, makes sense, body of request : <add><doc /></add>.

it seems no fields getting picked up. looking further, 'attributesmappingmanager' return 0 results. method below , commented results seeing 'getpropertieswithattribute'.

var props = type.getproperties(bindingflags.instance | bindingflags.public); //returns properties correctly var kvattrs = props.select(prop => new keyvaluepair<propertyinfo, t[]>(prop, type.getcustomattributes<t>())); // correct number of keys of properties solrnet attributes, values empty var propsattrs = kvattrs.where(kv => kv.value.length > 0); // 0 results return propsattrs; // 0 results 

i have tried breaking out test project , still same problems. have tried , without interface , still no luck. missing really simple, love know is.

note: using latest version of solrnet github repository

update tested 'samplesolrapp' solution, fixed references (couldn't find solrnet.dsl in 'homecontroller.cs', solrnet.dsl ref seemed missing, added reference compiled github repo), sample seems initialize correctly, posts 'exampledocs' via addinitialdocuments() method on application_start. works, however, shortly after error "the given key not present in dictionary." within 'htmlhelpermapperextensions.cs'. 'product' object does have correct attributes, field name mapper looking for, can't find fields('cat' in case). matches problem having not constructing valid http request solr because can't seem find solrfield attributes.

going test sample on pc see if problem dev environment. advice or suggestions appreciated.

update 2 tested on dev environment , getting same error. seems getcustomattributes extension methods not returning attributes on pocos even in sample. running samples on vs 2012 (.net 4.5, targeting 3.5 in sample project), iis express on win7 machine. hope might able point me in right direction further investigation.

first off, not sure why getting "document missing mandatory uniquekey field: id" error, because appear have decorated id property appropriately. since did not show how creating mypoco object, check setting id property (as id needs supplied (and unique) not auto-assigned solr). also, noticed that mapping of other fields text field in schema. not standard practice accomplishing behavior. typically mapping each property on poco separate field in schema (see mapping on solrnet project page example) , using copyfield directive in schema move of individual fields common text field. allows search on either combined text field or individual fields along enabling options such highlighting , faceting on individual fields.

please check out documents, fields , schema design more details on setting own custom fields , using copyfield. additionally, since have solrnet source github, recommend running , examining code in samplesolrapp directory working understanding of solrnet. can start sample via runsample.bat in source parent directory.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -