You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Neil Prosser <ne...@gmail.com> on 2015/01/15 16:17:04 UTC

DisMax search on field only if it exists otherwise fall-back to another

Hopefully this question makes sense.

At the moment I'm using a DisMax query which looks something like the
following (massively cut-down):

?defType=dismax
&q=some query
&qf=field_one^0.5 field_two^1.0

I've got some localisation work coming up where I'd like to use the value
of one, sparsely populated field if it exists, falling back to another if
it doesn't (rather than duplicating some default value for all territories).

Using the standard query parser I understand I can do the following to get
this behaviour:

?q=if(exist(field_one),(field_one:some query),(field_three:some query))

However, I don't know how I would go about using DisMax for this type of
fallback.

Has anyone tried to do this sort of thing before? Is there a way to use
functions within the qf parameter?