cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Search on Custom Type Property with 'OR'

b_victor
Champ in-the-making
Champ in-the-making
I am on 4.2.e Community, trying to customize Share advanced search.  I have a custom type, aq:qualityDoc defined, with a property named aq:documentType defined as:

<property name="aq:documentType">
   <title>Document Type</title>
   <type>d:text</type>
      <index enabled="true">
         <atomic>true</atomic>
         <stored>false</stored>
    <tokenised>both</tokenised>
      </index>
   <constraints>
      <constraint ref="aq:documentTypes" />
   </constraints>                
</property>

The associated constraint is defined as:

        <constraint name="aq:documentTypes" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>Description</value>
                    <value>Policy</value>
                    <value>Procedure</value>
                    <value>Evidence</value>
                    <value>Form</value>
                    <value>Other</value>
                </list>
            </parameter>
        </constraint>


I have configured advanced search, and the relevant part of my share-config-custom.xml looks like this:

<field id="aq:documentType" label-id="prop.aq_documentType">
   <control template="/org/alfresco/components/form/controls/selectmany.ftl" />
</field>


The form looks like exactly what I want the interface to look like… I can multi-select properties and perform a search from a selectmany control.  I do not get the appropriate results, though.  When there are multiple types selected, the query is translated into a search along the lines of this (obtained from turning up debug):

((TYPE:\"aq:qualityDoc\" AND (aq:documentType:\\\"Policy,Procedure,Form\\\")….


Obviously the above doesn't work, since what I really want is Policy OR Procedure OR Form.  Even when there is only one 'type' selected, I don't end up with any results (which I don't really understand). 

I'm pretty new to Alfresco, so please go easy on me…
1. What do I need to do to get advanced search working the way I want it to? 
2. Why does the query fail when I only have one document type selected (i.e. the query gets translated into something like:
((TYPE:\"aq:qualityDoc\" AND (aq:documentType:\\\"Form\\\"))….

3. Has anyone else seen behavior where when you go back to the "advanced search" dialog after performing a search, and it appears that there are no items selected in the control, but when the query is executed in fact the control has remembered what was previously selected?  Is there a way to ensure that previous selections are 'cleared' prior to resubmitting?

Many thanks for any help / tips provided.
BV
3 REPLIES 3

b_victor
Champ in-the-making
Champ in-the-making
I was just trying to figure out if a custom control was the way to go on this, of if there's a way to use an out-of-the-box control to get this working. I'd love any pointers, as I'm sure this sort of thing has been done before.
Thanks!

b_victor
Champ in-the-making
Champ in-the-making
I'm pulling my hair out on this… this seems like very basic functionality, but I can't get it to work.  I've followed all the tutorials and forum posts I can find, but the search doesn't work correctly.  If I use a "selectone.ftl" control on a search form, the search is limited to the default selection (i.e. no way to have "nothing" selected).  If I use a "selectmany.ftl" control, the search doesn't work when more than one is selected, because the selection gets translated into the query as a comma separated list.  How can one do advanced search on list-constrained properties? Any pointers appreciated…

b_victor
Champ in-the-making
Champ in-the-making
I solved this with something of a hack. In the share-config-custom.xml I set the appearance element for the control as follows:

<field id="aq:documentType" label-id="prop.aq_documentType">
   <control template="/org/alfresco/components/form/controls/selectone.ftl" >
       <control-param name="options">|Any,Description,Policy,Procedure,Evidence,Form,Other</control-param>
   </control>
</field>


The control defaults to the "|Any" which uses Any as a label, but is blank and hence omitted when evaluated for the query string. The problem with this solution is that you can't search on multiple values at once, and the values are hard-coded in the custom config file making maintenance harder.  Both of these are unfortunate, but at least the core functionality is there.  If anyone has a better way to solve this, I'd love to hear it.