0
votes

Let's say I have the following documents in Solr 6.4.2.

 <doc>
    <field name="id">1</field>
    <field name="solr_record_type">1</field>
    <field name="title">Fabulous Book</field>
    <field name="author">Angelo Author</field>
    <doc>
        <field name="id">1-1</field>
        <field name="solr_record_type">2</field>
        <field name="contributor_name">Polly Math</field>
        <field name="contributor_type">3</field>
    </doc>
</doc>

<doc>
    <field name="id">2</field>
    <field name="solr_record_type">1</field>
    <field name="title">Wonderful Book</field>
    <field name="author">Andrew Author</field>
    <doc>
        <field name="id">2-1</field>
        <field name="solr_record_type">2</field>
        <field name="contributor_name">Polly Math</field>
        <field name="contributor_type">4</field>
    </doc>
    <doc>
        <field name="id">2-2</field>
        <field name="solr_record_type">2</field>
        <field name="contributor_name">Carlos Composer</field>
        <field name="contributor_type">3</field>
    </doc>
</doc>

I want to return the document that has a child document with Polly Math as the contributor_name and 3 as the contributor_type. contributor_name is a text field which I'm also indexing into a phonetic field, but contributor_type is just an int.

The following query parameters return both records and does not do any limiting by contributor type:

q={!parent which="solr_record_type:1" v=$q_composer_name}
q_composer_name=_query_:"{!dismax qf=\"contributor_name^2.0 contributor_name_phonetic^2.0\" pf=\"contributor_name^2.0 contributor_name_phonetic^2.0\" tie=0.05}Polly"
fl=*,[child parentFilter="solr_record_type:1"]

How can I update this query so that I return the record with id=1 and not the record with id=2?

1

1 Answers

1
votes

To be fair, I don’t see any filter by contributor_type that you want.

So, I would only add it to the local parameter that you’re using to make your q_composer_name the following:

q_composer_name=+_query_:"{!dismax qf=\"contributor_name^2.0 contributor_name_phonetic^2.0\" pf=\"contributor_name^2.0 contributor_name_phonetic^2.0\" tie=0.05}Polly" +contributor_type:3

I’ve added missing section +contributor_type:3 to make this clause a must. Also, added a + to the dismax query as well, to make it truly Polly AND type 3