David Bulté
David Bulté

Reputation: 3109

In Solr, how to use edismax with filter queries (but without a default field)?

I have an edismax query with faceting enabled. I haven't specified a default field (neither in the select clause nor in the solrconfig.xml), as I only want to search on the fields specified in the 'qf' parameter. (I have the impression that if I do specify a default field, that field is also taken into account).

Here's the query:

/select?q=david&defType=edismax&qf=firstname^1+lastname^10&facet=true&facet.field=organization

So far everything works as expected: I get some results and there are also some results from the faceted search, e.g.

When I now click on one of the organizations, I want to search only within the set of documents that belong to that organization, hence the use of a filter query. However, when I add such a 'filterQuery' (fq), Solr complains that

no field name specified in query and no default specified via 'df' param.

So does that mean I do have to add some kind of 'catch-all' default field? But this doesn't seem logical, as all search fields are already specified in the 'qf'?

Here's my query:

/select?q=david&defType=edismax&qf=firstname^1+lastname^10&fq=organization:UZ+Leuven

And here is the output from the query:

{
  responseHeader: {
    status: 400,
    QTime: 1,
    params: {
      q: "david",
      qf: "firstname^1 lastname^10",
      wt: "json",
      fq: "organization:UZ Leuven",
      defType: "edismax"
    }
  },
  error: {
    msg: "no field name specified in query and no default specified via 'df' param",
    code: 400
  }
}

Upvotes: 3

Views: 2978

Answers (1)

MatsLindh
MatsLindh

Reputation: 52802

You probably want organization:"UZ Leuven", as it's complaining about a missing field name for Leuven. The standard query syntax for the fq parameter is the lucene syntax.

If you want to use the edismax/dismax query syntax for the fq parameter, you'll have to tell Solr to use the edismax parser through LocalParams:

fq={!type=edismax qf=$fqqf}organization:UZ Leuven&fqqf=field1 field2 field3

or possibly

fq={!type=edismax qf='field1 field2 field3'}organization:UZ Leuven

Upvotes: 1

Related Questions