Jason
Jason

Reputation: 2887

Using default value for Solr field boosting when field does not exist

My existing Solr 4.x instance has about 650k documents indexed. I just added a new field to the schema that will hold a number of votes given to the document that will be used in boosting the score. Until the first user up votes (or down votes) a given document, said document will not have that field defined. You can see this when viewing the document using the Solr Admin tool.

The field was defined with a default value but I think this only applies to new documents (or maybe reindexed documents) that do not have said field specified.

When I try to test out different boosting functions, I get the following exception back

  "error": {
    "msg": "can not use FieldCache on a field which is neither indexed nor has doc values: votes",
    "code": 400
  }

Is it possible to specify a default value to be used for boosting when the field does not (yet) exist in the document? My logic would be

Upvotes: 1

Views: 1500

Answers (1)

leoh
leoh

Reputation: 10608

This seems to related to your earlier question. Perhaps you can try the FuntionQuery as well

 q={!boost b=map(field,0,0,0,default_value) } your_query

This will boost based on the field value, and use default_value if the field value is null.

Reference here

Upvotes: 1

Related Questions