cancel
Showing results for 
Search instead for 
Did you mean: 

Search on custom property not returning results

heisenberg
Champ in-the-making
Champ in-the-making
I had modified the stock contentModel.xml by adding a custom property "mycustomprop1" to cm:content as follows:


     <type name="cm:content">
         <title>Content</title>
         <parent>cm:cmobject</parent>
         <archive>true</archive>
         <properties>
            <property name="cm:content">
               <type>d:content</type>
               <mandatory>false</mandatory>
               <!– Although content is marked as indexed atomically it may end up asynchronous –>
               <!– if the content conversion will take too long. Content that does not require conversion –>
               <!– to UTF8 test/plain will always be indexed atomically –>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
            <property name="cm:mycustomprop1">
               <title>My Custom Property</title>
               <type>d:text</type>
               <protected>false</protected>
               <mandatory>false</mandatory>
               <index enabled="true">
                   <atomic>true</atomic>
                     <stored>true</stored>
                     <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
      </type>


Then I proceeded to add a couple of nodes with FileFolderService, and set the property to "ZACK". But searching for the custom property fails, but if I search for the type I can see the nodes.


   SearchParameters params = new SearchParameters();
        params.addStore(storeRef);
        params.setLanguage(SearchService.LANGUAGE_LUCENE);
        params.setQuery("@cm\\:mycustomprop1:\"ZACK\"");  /* This returns 0 hits?!? */
        //params.setQuery("TYPE:\"cm:content\""); /* This returns the 2 nodes as expected. */
        ResultSet results = searchService.query(params);


What am I missing here? Yes, I am 100% sure I successfully added the "ZACK" property to the nodes, I verified that by reading it back with NodeService.getProperty().

3 REPLIES 3

anshu_kumar
Star Contributor
Star Contributor
Hi Heisenberg,

For that, you will have to mention the name of your custom property, i.e "cm:mycustomprop1" in 'search.get.config.xml'.

The mentioned file can be found under file path  {server_path}\webapps\alfresco\WEB-INF\classes\alfresco\templates\webscripts\org\alfresco\slingshot\search\search.get.config.xml

In this file, you will see set of properties which are used for searching.

heisenberg
Champ in-the-making
Champ in-the-making
Anshu, I'm not using the Alfresco UI, so the webscript template configuration does not apply in my case. I'm interacting with Alfresco NodeService, FileFolderService, and SearchService programmatically, i.e. Java-only through the SDK.

castgroupteam
Champ in-the-making
Champ in-the-making
Hi Heisenberg (or I have to call you Walter White? Smiley Happy )
First of all you have to know that modifing the out of the box contentModel is not a good practice, it's better to use a custom aspect.
However,assuming you know what are you doing, you can try doing a full reindex because of the existing system nodes still apply the old model.
Have you tried to query a standard property like cm:name? Does it work?
Looking at the node browser you can see your property with the correct type and the correct value?

Regards,
Daniele