cancel
Showing results for 
Search instead for 
Did you mean: 

Advance search on custom properties are not working

abhinav
Champ on-the-rise
Champ on-the-rise
Hi Team,

I was trying to implement the advance search in Alfresco 5.0.a, I have gone through Jeff's blog:
http://ecmarchitect.com/alfresco-developer-series-tutorials/content/tutorial/tutorial.html

But search on custom properties are not working at all.

I have done following steps:
I downloaded the "Alfresco-Developer-Series" projects from https://github.com/jpotts/alfresco-developer-series
I created the amp (content-tutorial-repo & content-tutorial-share) files and deployed to Alfresco and share. Content model is working fine.
I am also able to see the Advance search options for SomeCo Whitepaper with Product, Version and IsActive fields.

But when i am trying to search by providing some values to the above mentioned fields i am not getting any search result.

I have updated the document properties with values for Product, Version and IsActive properties already.

For example: Say i have updated Product and Version of a document property is "MyProduct" and "2.0.0".

When Searching with value "MyProduct" for Product field, i am getting 0 results.
When Searching with value "2.0.0" for Verison field, i am getting 0 results.
i.e. search on custom properties are not working at all.
whereas when searching with Modifier,Created,Title (Properties of out-of-box content model) etc. i am getting results.

Search URL formed after clicking the search button::::

http://127.0.0.1:8080/share/page/site/archivepoc/search?t=&q={'prop_cm_name':'','prop_cm_title':'','...

See the screen shots for details.

Share configs:

Share-custom-config.xml:
<alfresco-config>
   <!– Document Library config section –>
   <config evaluator="string-compare" condition="DocumentLibrary">
      <!–
         Used by the "Manage Aspects" action

         For custom aspects, remember to also add the relevant i18n string(s)
            cm_myaspect=My Aspect
      –>
      <aspects>
         <!– Aspects that a user can see –>
         <visible>
            <aspect name="sc:webable" />
            <aspect name="scSmiley TongueroductRelated" />           
         </visible>

         <!– Aspects that a user can add. Same as "visible" if left empty –>
         <addable>
         </addable>

         <!– Aspects that a user can remove. Same as "visible" if left empty –>
         <removeable>
         </removeable>
      </aspects>

      <!–
         Used by the "Change Type" action

         Define valid subtypes using the following example:
            <type name="cm:content">
               <subtype name="cm:mysubtype" />
            </type>

         Remember to also add the relevant i18n string(s):
            cm_mysubtype=My SubType
      –>
      <types>
             <type name="cm:content">
                <subtype name="sc:doc" />
                <subtype name="sc:whitepaper" />
             </type>
             <type name="sc:doc">
                <subtype name="sc:whitepaper" />
             </type>
      </types>
   </config>
  
   <config replace="true" evaluator="string-compare" condition="AdvancedSearch">
      <advanced-search>
         <!– Forms for the advanced search type list –>
         <forms>
            <!–
               The 'form' config element contains the name of the model type
               of the form to display.
              
               The element supports the following optional attributes:
                  id = form id, the id of "search" will be assumed if not set
                  label = label text to display - defaults to model type if not set
                  labelId = I18N message id of label text to display
                  description = description text to display
                  descriptionId = I18N message id of description text to display
            –>
            <form labelId="search.form.label.cm_content" descriptionId="search.form.desc.cm_content">cm:content</form>
            <form labelId="search.form.label.cm_folder" descriptionId="search.form.desc.cm_folder">cm:folder</form>           
            <form labelId="type.sc_whitepaper" descriptionId="search.form.desc.sc_whitepaper">sc:whitepaper</form>
        
         </forms>
      </advanced-search>
   </config>

   <!– sc:whitepaper type (existing nodes) –>
   <config evaluator="node-type" condition="sc:whitepaper">
      <forms>
         <!– Default form configuration for the sc:whitepaper type –>
         <form>
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="mimetype" />
               <show id="cm:author" force="true" />
               <show id="size" for-mode="view" />
               <show id="cm:creator" for-mode="view" />
               <show id="cm:created" for-mode="view" />
               <show id="cm:modifier" for-mode="view" />
               <show id="cm:modified" for-mode="view" />
              
               <!– tags and categories –>
               <show id="cm:taggable" for-mode="edit" force="true" />
               <show id="cm:categories" />
              
               <!– cm:dublincore aspect –>
               <show id="cmSmiley Tongueublisher"/>
               <show id="cm:contributor"/>
               <show id="cm:type"/>
               <show id="cm:identifier"/>
               <show id="cm:dcsource"/>
               <show id="cm:coverage"/>
               <show id="cm:rights"/>
               <show id="cm:subject"/>
              
               <!– cm:complianceable aspect –>
               <show id="cm:removeAfter" />
              
               <!– cm:effectivity aspect –>
               <show id="cm:from"/>
               <show id="cm:to"/>
              
               <!–  cm:summarizable aspect –>
               <show id="cm:summary" />
              
               <!– cm:translatable aspect –>
               <show id="cm:translations" />
              
               <!– cm:localizable aspect –>
               <show id="cm:locale" />
              
               <!– cmSmiley Surprisedwnable aspect –>
               <show id="cmSmiley Surprisedwner" />
              
               <!– cm:attachable aspect –>
               <show id="cm:attachments" />
              
               <!– cm:emailed aspect –>
               <show id="cmSmiley Surprisedriginator" />
               <show id="cm:addressee" />
               <show id="cm:addressees" />
               <show id="cm:sentdate" />
               <show id="cm:subjectline" />
              
               <!– exif:exif aspect –>
               <show id="exif:dateTimeOriginal" />
               <show id="exifSmiley TongueixelXDimension" />
               <show id="exifSmiley TongueixelYDimension" />
               <show id="exif:exposureTime" />
               <show id="exif:fNumber" />
               <show id="exif:flash" />
               <show id="exif:focalLength" />
               <show id="exif:isoSpeedRatings" />
               <show id="exif:manufacturer" />
               <show id="exif:model" />
               <show id="exif:software" />
               <show id="exifSmiley Surprisedrientation" />
               <show id="exif:xResolution" />
               <show id="exif:yResolution" />
               <show id="exif:resolutionUnit" />

               <!– audio:audio aspect –>
               <show id="audio:album" />
               <show id="audio:artist" />
               <show id="audio:composer" />
               <show id="audio:engineer" />
               <show id="audio:genre" />
               <show id="audio:trackNumber" />
               <show id="audio:releaseDate" />
               <show id="audio:sampleRate" />
               <show id="audio:sampleType" />
               <show id="audio:channelType" />
               <show id="audio:compressor" />
              
               <!– cm:indexControl aspect –>
               <show id="cm:isIndexed" />
               <show id="cm:isContentIndexed" />
              
               <!– cm:geographic aspect –>
               <show id="cm:latitude" />
               <show id="cm:longitude" />
              
               <!– sc:doc –>
               <show id="sc:relatedDocuments" />
            </field-visibility>
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:description">
                  <control>
                     <control-param name="activateLinks">true</control-param>
                  </control>
               </field>
               <field id="mimetype">
                  <control template="/org/alfresco/components/form/controls/mimetype.ftl" />
               </field>
               <field id="size">
                  <control template="/org/alfresco/components/form/controls/size.ftl" />
               </field>
               <field id="cm:taggable">
                  <control>
                     <control-param name="compactMode">true</control-param>
                     <control-param name="params">aspect=cm:taggable</control-param>
                     <control-param name="createNewItemUri">/api/tag/workspace/SpacesStore</control-param>
                     <control-param name="createNewItemIcon">tag</control-param>
                  </control>
               </field>
               <field id="cm:categories">
                  <control>
                     <control-param name="compactMode">true</control-param>
                  </control>
               </field>
               <field id="cmSmiley Surprisedriginator" read-only="true" />
               <field id="cm:addressee" read-only="true" />
               <field id="cm:addressees" read-only="true" />
               <field id="cm:sentdate" read-only="true" />
               <field id="cm:subjectline" read-only="true" />
               <field id="sc:relatedDocuments" label-id="assoc.sc_relatedDocuments"/>
            </appearance>
         </form>

         <!– Document Library pop-up Edit Metadata form –>
         <form id="doclib-simple-metadata">
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <!– tags and categories –>
               <show id="cm:taggable" for-mode="edit" force="true" />
               <show id="cm:categories" />
               <!– sc:doc –>
               <show id="sc:relatedDocuments" />              
            </field-visibility>
            <edit-form template="../documentlibrary/forms/doclib-simple-metadata.ftl" />
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:description">
                  <control>
                     <control-param name="activateLinks">true</control-param>
                  </control>
               </field>
               <field id="cm:taggable">
                  <control>
                     <control-param name="compactMode">true</control-param>
                     <control-param name="params">aspect=cm:taggable</control-param>
                     <control-param name="createNewItemUri">/api/tag/workspace/SpacesStore</control-param>
                     <control-param name="createNewItemIcon">tag</control-param>
                  </control>
               </field>
               <field id="cm:categories">
                  <control>
                     <control-param name="compactMode">true</control-param>
                  </control>
               </field>
               <field id="sc:relatedDocuments" label-id="assoc.sc_relatedDocuments" />
            </appearance>
         </form>
        
         <!– Document Library Inline Edit form –>
         <form id="doclib-inline-edit">
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="cm:content" force="true" />
            </field-visibility>
            <appearance>
               <field id="cm:name">
                 <control>
                    <control-param name="maxLength">255</control-param>
                 </control>
               </field>
               <field id="cm:title">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="cm:content">
                  <control>
                     <control-param name="editorAppearance">explorer</control-param>
                     <control-param name="forceEditor">true</control-param>
                  </control>
               </field>
            </appearance>
         </form>
      </forms>
   </config>
  
   <config evaluator="aspect" condition="sc:webable">
       <forms>
          <form>
              <field-visibility>
                   <show id="scSmiley Tongueublished" />
                   <show id="sc:isActive" />
              </field-visibility>
              <appearance>                
                 <field id="scSmiley Tongueublished" label-id="prop.sc_published" />
                 <field id="sc:isActive" label-id="prop.sc_isActive" />
               </appearance>
          </form>
      </forms>
   </config>

   <config evaluator="aspect" condition="scSmiley TongueroductRelated">
      <forms>
         <form>
            <field-visibility>
                <show id="sc:version" />
                <show id="scSmiley Tongueroduct" />
            </field-visibility>
            <appearance>                
                <field id="scSmiley Tongueroduct" label-id="prop.sc_product" />
                <field id="sc:version" label-id="prop.sc_version" />
         </appearance>
         </form>
      </forms>
   </config>
  
   <!– sc:whitepaper type (new nodes) –>
   <config evaluator="model-type" condition="sc:whitepaper">
      <forms>
         <!– Search form –>
         <form id="search">
            <field-visibility>
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
               <show id="mimetype" />
               <show id="cm:modified" />
               <show id="cm:modifier" />
               <!– scSmiley TongueroductRelated –>
               <show id="scSmiley Tongueroduct" />
               <show id="sc:version" />
               <!– sc:webable –>
               <show id="sc:isActive" />
               <show id="scSmiley Tongueublished" />
            </field-visibility>
            <appearance>
               <field id="mimetype">
                  <control template="/org/alfresco/components/form/controls/mimetype.ftl" />
               </field>
               <field id="cm:modifier">
                  <control>
                     <control-param name="forceEditable">true</control-param>
                  </control>
               </field>
               <field id="cm:modified">
                  <control template="/org/alfresco/components/form/controls/daterange.ftl" />
               </field>
               <!– scSmiley TongueroductRelated –>
               <field id="scSmiley Tongueroduct" label-id="prop.sc_product">
                   <control template="/org/alfresco/components/form/controls/textfield.ftl" />
               </field>
               <field id="sc:version" label-id="prop.sc_version">
                   <control template="/org/alfresco/components/form/controls/textfield.ftl" />
            </field>              
               <!– sc:webable –>
               <field id="sc:isActive" label-id="prop.sc_isActive">
                   <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>
               <field id="scSmiley Tongueublished" label-id="prop.sc_published">
                   <control template="/org/alfresco/components/form/controls/daterange.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>
</alfresco-config>

scModel.properties:

#sc:doc
type.sc_doc=SomeCo Doc
assoc.sc_relatedDocuments=Related Documents

#sc:whitepaper
type.sc_whitepaper=SomeCo Whitepaper
search.form.desc.sc_whitepaper=Search for SomeCo Whitepapers

#sc:webable
aspect.sc_webable=SomeCo Webable
prop.sc_published=Published
prop.sc_isActive=Active?

#scSmiley TongueroductRelated
aspect.sc_productRelated=SomeCo Product Related
prop.sc_product=Product
prop.sc_version=Version

Repo config for SomeCoModel:

<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="sc:somecomodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>
   <description>Someco Model</description>
   <author>Jeff Potts</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>
   <imports>
      <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
      <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>      
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.someco.com/model/content/1.0" prefix="sc" />
   </namespaces>
   <constraints>
       <constraint name="sc:campaignList" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>Application Syndication</value>
                    <value>Private Event Retailing</value>
                    <value>Social Shopping</value>
                </list>
            </parameter>
        </constraint>
    </constraints>

   <types>
      <!– Enterprise-wide generic document type –>
      <type name="sc:doc">
         <title>Someco Document</title>
         <parent>cm:content</parent>
         <associations>
            <association name="sc:relatedDocuments">
               <title>Related Documents</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>sc:doc</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
         <mandatory-aspects>
           <aspect>cm:generalclassifiable</aspect>
         </mandatory-aspects>
      </type>

      <type name="sc:whitepaper">
         <title>Someco Whitepaper</title>
         <parent>sc:doc</parent>
      </type>

        <type name="sc:marketingDoc">
                <title>Someco Marketing Document</title>
                <parent>sc:doc</parent>
                <properties>
                        <property name="sc:campaign">
                                <type>d:text</type>
                                <multiple>true</multiple>
                                <constraints>
                                        <constraint ref="sc:campaignList" />
                                </constraints>
                        </property>
                </properties>
        </type>
      <type name="sc:client">
         <title>Someco Client</title>
         <parent>sys:base</parent>
         <properties>
            <property name="sc:clientName">
               <type>d:text</type>
            </property>
            <property name="sc:clientId">
               <type>d:text</type>
            </property>
         </properties>
      </type>
   </types>

   <aspects>
      <aspect name="sc:webable">
         <title>Someco Webable</title>
         <properties>
            <property name="scSmiley Tongueublished">
               <type>d:date</type>
            </property>
            <property name="sc:isActive">
               <type>d:boolean</type>
               <default>false</default>
            </property>
         </properties>
      </aspect>
      
      <aspect name="scSmiley TongueroductRelated">
         <title>Someco Product Metadata</title>
         <properties>
            <property name="scSmiley Tongueroduct">
               <type>d:text</type>               
               <mandatory>true</mandatory>
               <multiple>true</multiple>               
            </property>            
            <property name="sc:version">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <multiple>true</multiple>
            </property>
         </properties>
      </aspect>
      
      <aspect name="sc:clientRelated">
         <title>Someco Client Related</title>
         <associations>
            <association name="sc:relatedClients">
               <title>Related Clients</title>
               <source>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </source>
               <target>
                  <class>sc:client</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
      </aspect>   
   </aspects>
</model>

#sc:doc
sc_somecomodel.type.sc_doc.title=SomeCo Doc
sc_somecomodel.association.sc_relatedDocuments.title=Related Documents

#sc:whitepaper
sc_somecomodel.type.sc_whitepaper.title=SomeCo Whitepaper
sc_somecomodel.search.form.desc.sc_whitepaper.title=Search for SomeCo Whitepapers

#sc:webable
sc_somecomodel.aspect.sc_webable.title=SomeCo Webable
sc_somecomodel.property.sc_published.title=Published
sc_somecomodel.property.sc_isActive.title=Active?

#scSmiley TongueroductRelated
sc_somecomodel.aspect.sc_productRelated.title=SomeCo Product Related
sc_somecomodel.property.sc_product.title=Product
sc_somecomodel.property.sc_version.title=Version

context:
<beans>

    <!– Registration of new models –>
    <bean id="${project.artifactId}_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/module/${project.artifactId}/model/scModel.xml</value>
            </list>
        </property>
        <property name="labels">
            <list>
                <value>alfresco/module/${project.artifactId}/messages/scModel</value>
            </list>       
        </property>
    </bean>

</beans>
2 REPLIES 2

vicsaego
Champ in-the-making
Champ in-the-making
Have you found any solution? I have the same problem, advanced search is not working.

tsafarog
Champ on-the-rise
Champ on-the-rise
eventhough it has been a long time since i have made a model in alfresco i believe you are missing the indexing defaults for your properties

<index enabled="true">
  <atomic>true</atomic>
  <stored>false</stored>
  <tokenised>true</tokenised>
</index>


http://docs.alfresco.com/community/concepts/search-fts-config.html