Boost by Field in a Dictionary<string,object>

148 views
Skip to first unread message

[mRg]

unread,
Jan 24, 2013, 11:43:28 AM1/24/13
to sol...@googlegroups.com
Hi all,

For complicated reasons, that i wont go into, I'm inserting my data into Solr using Document<string,object> objects. This means I am able to add boost per item using AddWithBoost and KeyValuePair<Dictionary<string,object>,float>

The missing part of this puzzle is when someone wants to boost at a field level .. normally this is done via an attribute [SolrField("field", Boost = 20)] .. obviously I dont have this :/

The only possibilities I can think of getting round this are: 

1) To add something into the AddParameters that contains a map of (DocumentUniqueId,FieldName,Boost) and this just applies it as part of the add ?
2) Could I change my Document<string,object> into a Dictionary<string,SolrFieldModel> and would it get processed the same ?
3) Is it down to writing my own mapping manager ?

Any guidance is always appreciated :)

Regards

Stephen / mRg

Mauricio Scheffer

unread,
Jan 24, 2013, 4:57:38 PM1/24/13
to sol...@googlegroups.com
Hi Stephen,

I think the easiest way would be to implement your own ISolrDocumentSerializer<Dictionary<string, object>> (use the default SolrDictionarySerializer for reference, it's quite simple).
This new serializer could have a fixed table of boosts per field. Or you could use a new BoostedField class that wraps the field value plus its boost, then in the new serializer check if the object is an instance of BoostedField and apply the corresponding boost.

Cheers



--
Mauricio


--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

[mRg]

unread,
Jan 25, 2013, 4:38:25 AM1/25/13
to sol...@googlegroups.com
Thanks Mauricio.. it worked perfectly. Thank you very much ! I went with the SolrBoostedField class in the end, like you said, very simple. Happy to submit back to the project if it would be useful for anyone else ?

Stephen
Reply all
Reply to author
Forward
0 new messages