cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple dynamic aspects and full text indexing

mrsaqib
Champ in-the-making
Champ in-the-making
Hi,

I have disabled content indexing in contentModel.xml file as I have my own custom aspect (say Aspect1) and properties defined in my model & that's working fine.The documents of these aspects are loaded in some specific space , say Space1.

Now I want to create another space, say Space2, and want to attach another aspect(different from above), say Aspect2, but also want to enable content indexing only for this aspect(documents). how can i achieve this?

I'll create another model in data dictionary, attach the aspect but how content indexing can be turn ON only for documents having this aspect (Aspect2)??

Please suggest!!!

Kind Regards
9 REPLIES 9

abarisone
Star Contributor
Star Contributor
HI,
from Alfresco 4.0.d on it is possible to control indexing on a particular content type exploiting the cm:indexControl aspect, provided with basic contentModel.xml:
<!–                  –>
      <!– Indexing control –>
      <!–                  –>
     
      <aspect name="cm:indexControl">
         <title>Index Control</title>
         <properties>
            <property name="cm:isIndexed">
               <title>Is indexed</title>
               <type>d:boolean</type>
               <default>true</default>
            </property>
            <property name="cm:isContentIndexed">
               <title>Is content indexed</title>
               <type>d:boolean</type>
               <default>true</default>
            </property>
         </properties>
      </aspect>

You can also do this using Java:

NodeService nodeService = uirnetBl.getNodeService();
QName contentTypeQname = QName.createQName(<yourModelNamespace>, <yourCustomType>);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_NAME, tempFileOut.getName());
properties.put(ContentModel.PROP_IS_INDEXED, false);
properties.put(ContentModel.PROP_IS_CONTENT_INDEXED, false);
ChildAssociationRef children = nodeService.createNode(parent.getNodeRef(), ContentModel.ASSOC_CONTAINS,
            DataDictionaryHelper.getAssocNameFromFileName(tempFileOut.getName()), contentTypeQname, properties);
NodeRef newNode = children.getChildRef();
ContentWriter writer = contentService.getWriter(newNode, ContentModel.PROP_CONTENT, true);

where ContentModel.PROP_IS_INDEXED specifies whether to index node properties or not, whereas PROP_IS_CONTENT_INDEXED specifies if content indexing is required or not.

Regards,
Andrea

mrsaqib
Champ in-the-making
Champ in-the-making
Thanks.

But can you please tell me how can i get reference to DataDictionaryHelper   ( DataDictionaryHelper.getAssocNameFromFileName())??

abarisone
Star Contributor
Star Contributor
Hi,
DataDictionaryHelper is just a support class that I use to manage DataDictionary objects.
You can build your own adding this method to make previous code compile:
public static QName getAssocNameFromFileName(String name) {
     // TODO: convert name to ISOwhatever encoding
     return QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name);
}
Regards,
Andrea

mrsaqib
Champ in-the-making
Champ in-the-making
Thanks, the code works, now the problem is

the file is UPLOADED with IsContentIndexed = true, but still i am unable to search it with full text (I am assuming, the alfresco quick search will retrieve this document when i enter text from this file).

Please see the screen shot

[img]https://dl.dropbox.com/u/6103508/Details%20of%20%27Q0150618-01-5536-2012-09-24_01-44-46.png[/img]

Any suggestion?

abarisone
Star Contributor
Star Contributor
Hi,
I can't see your screenshot, but from Alfresco Web Client try with an advanced search based on content

Regards,
Andrea

mrsaqib
Champ in-the-making
Champ in-the-making
Hi,
I can't see your screenshot, but from Alfresco Web Client try with an advanced search based on content

Regards,
Andrea

In Screen shot, i just wanted to show  the properties values :
   Is Indexed:   Yes
   Is Content Indexed:   Yes

I tried with advance search as well, but no result.

Here is what cm:content type is in contentMode.xml

<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="false">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
      </type>

mrsaqib
Champ in-the-making
Champ in-the-making
Ok what i have done is, made cm:content indexing = true,

and IsContentIndex = true when i want to set full text search and false when not.

I am also able to search content in alfresco client on those files where IsContentIndex is true;

I hope this is correct implementation.

abarisone
Star Contributor
Star Contributor
HI,
well if I correctly understood your requirements you would show isContentIndexed and isIndexed aspects in your results using Alfresco Web Client?
If so you can modify web-client-config-custom.xml and modify the config evaluator related to node-types:
<config evaluator="node-type" condition="<yourCustomNameSpace:yourCustomTyoe>">
      <property-sheet>
         <show-property name="yourCustomNameSpace:prop1"/>
         <show-property name="yourCustomNameSpace:prop2"/>       
      </property-sheet>
   </config>
Here http://wiki.alfresco.com/wiki/Advanced_Search_Custom_Attributes more info about this.
Regards,
Andrea

abarisone
Star Contributor
Star Contributor
Hi,
okay with your solution, but I would suggest to extend cm:content base class and build up your own tree, because you could have different requirements.

Regards,
Andrea