0

I am trying to use solr 'def' function with bf , but it is not working as given in documentation

The documentation says : def is short for default. Returns the value of field "field", or if the field does not exist, returns the default value specified. Yields the first value where exists()==true.

Syntax Examples

def(rating,5): This def() function returns the rating, or if no rating specified in the doc, returns 5 def(myfield, 1.0): equivalent to if(exists(myfield),myfield,1.0)

http://localhost:8983/solr/mycollection/select?q=name:milk&bf=if(exists(myfield),myfield,1.0)

or

http://localhost:8983/solr/mycollection/select?q=name:milk&bf=def(myfield,1.0)

Exected result is 1 if myfield does not exists

dname
  • 153
  • 2
  • 10

1 Answers1

0

You have forgotten to use defType=edisMax or disMax

defType=edismax&bf=def(myfield,1)

You can test also def function in fl fields to see the output

select?fl=def(myfield,10)
Oyeme
  • 11,088
  • 4
  • 42
  • 65