Search results different Document types

I have created the following document types: Bc,Bl,facture; they are all linked by the field num_bc. I created a local search by num_bc, my issue is that the search can results only one of the three document types but not all of them.

here's what I've tried:

<coreQueryPageProvider>
        <property name="coreSession">#{documentManager}</property>
        <property name="maxResults">DEFAULT_NAVIGATION_RESULTS</property>
        <whereClause docType="liasse_search">
          <predicate parameter="bc:num_bc" operator="=">
            <field schema="liasse_search" name="num_bc" />
          </predicate>
          <predicate parameter="bl:num_bc" operator="=">
            <field schema="liasse_search" name="num_bc" />
          </predicate>
          <predicate parameter="fctr:num_bc" operator="=">
            <field schema="liasse_search" name="num_bc" />
          </predicate>
          <fixedPart>
                ecm:isCheckedInVersion = 0 AND
                        ecm:mixinType != 'HiddenInNavigation' AND 
                        ecm:currentLifeCycleState != 'deleted' AND
                        ecm:primaryType = 'bc' OR ecm:primaryType = 'bl' OR ecm:primaryType = 'facture'  
          </fixedPart>
      <sort column="dc:title" ascending="true" />
        <pageSize>20</pageSize>     
        </whereClause>
      </coreQueryPageProvider>
0 votes

1 answers

2617 views

ANSWER



Hi Dalal, the 3 document types must have those fields in common in the same schema and when you execute this query, it SUMS the three fields like an “AND” instead an “OR”. I did something like this in my project. This is the coreQuery:

            <whereClause docType="liasse_search">
                <fixedPart>
                    ecm:primaryType IN ('b1',
                    'facture',
                    'bc')
                    AND ecm:mixinType !=
                    'HiddenInNavigation'
                    AND NOT (ecm:mixinType = 'Collection' AND
                    ecm:name = 'Locally
                    Edited')
                    AND ecm:isCheckedInVersion = 0
                    AND
                    ecm:currentLifeCycleState != 'deleted'
                    AND SORTED_COLUMN IS NOT
                    NULL
                </fixedPart>

You also have to create a schema with with num_bc (num_schema in the following code), add this schema to your three types, and create in this schema the field “num_bc”

    <doctype  name="facture" extends="Document">
        <schema name="num_schema" />
        <schema name="facture_schema" />
    </doctype>

    <doctype  name="b1" extends="Document">
        <schema name="num_schema" />
        <schema name="b1_schema" />
    </doctype>

    <doctype  name="b2" extends="Document">
        <schema name="num_schema" />
        <schema name="b2_schema" />
    </doctype>

You also can do it with hierachy with a supertype

For example

    <doctype name="myCustomSuperType" extends="Document">
        <schema name="myCustomSuperType_schema" />
    </doctype>

    <doctype  name="facture" extends="myCustomSuperType">
        <schema name="facture_schema" />
    </doctype>

    <doctype  name="b1" extends="myCustomSuperType">
        <schema name="b1_schema" />
    </doctype>

I hope this helps you.

EDIT: This solution should also work for you without creating a new schema (using parameters instead of predicates)

<fixedPart>
    ecm:isCheckedInVersion = 0 AND
    ecm:currentLifeCycleState != 'deleted' AND
    ( ecm:primaryType = 'bc' OR ecm:primaryType = 'bl' OR ecm:primaryType = 'facture'  ) AND
    ( bc:num_bc = ? OR
      b1:num_bc = ? OR fctr:num_bc = ?) ) 
  </fixedPart>      
</whereClause>
  <parameter>#{searchDocument.liasse_search.num_bc}</parameter>
  <parameter>#{searchDocument.liasse_search.num_bc}</parameter>
  <parameter>#{searchDocument.liasse_search.num_bc}</parameter>

https://answers.nuxeo.com/general/q/d0f8a109a7fc43689bc08e1fbc129053/About-the-coreQueryPageProvider-and-Predicate-fixedPart

1 votes



JVent I already resolved my problem using a schema containing num_bc and then add it to the three types as you mentioned. Thanks for the detailed answer.
07/24/2015