lucci
lucci

Reputation: 13

Query parent document using two filter clauses

I'm using Solr and I want to query a parent document using two constraints. It is currently working for just one contraint.

Example:

q={!parent which=type:parent}child_field:something

But I want to get parent documents that are defined as a parent (type attribute = "parent") AND have some specific word in field "name".

I've tried the following, but it returns an error:

q={!parent which=(type:parent) AND (name:someone)}child_field:something

org.apache.solr.search.SyntaxError: Expected identifier at pos 33 str='{!parent which=(type:parent) AND (name:someone)}child_field:something'

Upvotes: 0

Views: 360

Answers (1)

MatsLindh
MatsLindh

Reputation: 52912

According to the recommendation under the BlockJoinParentQueryParser:

Using which A common mistake is to try to filter parents with a which filter, as in this bad example:

q={!parent which="title:join"}comments:SolrCloud

Instead, you should use a sibling mandatory clause as a filter:

q=+title:join +{!parent which="content_type:parentDocument"}comments:SolrCloud

So deriving from that example, giving the required filter as the first mandatory clause should work:

q=+name:someone +{!parent which="type:parent"}child_field:something

Upvotes: 1

Related Questions