: I would like to use a query function to boost documents of a certain : "type". I realize that I can use a boost query for this, but in : analyzing the scoring it doesn't seem as predictable as the query : functions.
It should be fairly predictible, can you elaborate on what problems you have just adding boost queries for the specific types? if you us want simple boosting by type, i would use boost queries ... if you want the type to contribute to a more complex calculation, then yeah a function queyr is hte way to go... : Can this be done with function queries? the simplest approach would be to pick numeric constants for each type (BAR=>1, BAZ=>2) and index those in a numeric field -- you could still choose not to use them in some queries (unlike document boosts) but the downside is hte weighting would be the same for every function. : As a follow up, how difficult would it be for me to write my own : function (and plug it into Solr) that allowed me to return a 1.0 or 0.0 : if a field had a particular string value in it? A function that would : look something like "fieldEq(foo,BAR)" if you want BAR to be worth 1 in some queries and 5 in other queries, then writing a custom function is hte way to go. the way to implement it would be as a ValueSource -- ValueSources are the inputs to functions, (functions are themselves also ValueSources so they can be fed to other functions) and the lowest level ValueSources get their values from some contcrete location: ConstValueSource, FieldCacheSource, FileFloatSource. You could write a subclass of FieldCacheSource that looked at the StringIndex FieldCache to get the indexed term (BAR) and then map that to a number. to take advantage of your new ValueSource, you write a simple ValueSourceParser impl and add a <valueSourceParser> line to your solrconfig.xml registering it to the name you want ("fieldEq" in your example) a generic Parser/ValueSource that let you specific term=>float mappings in it's init params would certianly make a cool patch for Solr. -Hoss