michelle.rice

How to make Custom Content Type searchable

Discussion created by michelle.rice on Jun 18, 2010

Case #83245

Details


Status: Closed
Case Type: /
Severity: Level 3
Product: /
Component: Customizations
Environment: /
Internal Discussion Link: /

Description


I would like my custom content type to be searchable...

 

I followed the instructions http://www.jivesoftware.com/jivespace/docs/DOC-4962  but still not able to make my content type searchable..

 

Is there any other implementation that I need to make sure thats working? in order for the code on the instructions to be working..

 

I did noticed that getIndexFields gets call after creation of content type and viewing

protected Map<IndexField, String> getIndexFields(long id) {
..code
}

 

I would like to know what class on my custom content type is being called when they hit search button on the search page.. and the flow ..

 

Can anyone assist me on this?.. Any extra information will be helpful!


Comments


Hi Michele-

 

I am starting to look into this for you but I did have a couple of questions:

 

-What interface did you implement on your object type class?

-Did you implement all necessary providers?

-Do you have a plugin class that performs all necessary tasks (i.e. registering object type)?

 

In addition, have you perused this document? Content Type Framework

 

You may also want to check out our public Subversion repository and look at the plugin that implements a custom "memo" type:

https://svn.jivesoftware.com/svn/dev/repos/jive/plugins/memo-type-example/

 

-gabe



Hi Gabe, Thanks for your respond..

 

 

Here's my objectType class

 

 

public class MyObjectType implements ContentObjectType, ContainableType, CommunityTaggableType, 
             TaggableType, RecentContentEnabledType, FilteredIndexableType, RecentActivityEnabledType, 
             RecentHistoryEnabledType, CommentableType, FavoritableType, EntitlementCheckableType<MyObject>,
             ViewCountSupportedType {


            .. code setters and getters 
}

 

From my understanding what I need to implement for the content type to be searchable is FilteredIndexableType

 

I then implement BaseIndexProvider, from my understanding this method (getIndexFields) gets called when  an event is fired and during update of reindexing?

 

Also for extra note... My content type don't live in any container and any workspace.. the content  type is stand alone..

I don't save any containerId and a containertype in the database.. Will this matter when indexing/searching?

 

public class MyIndexInfoProvider extends BaseIndexInfoProvider { 


    @Override
    protected Map<IndexField, String> getIndexFields(long id) {


        MyObject object = mymanager.getObjectById(id);
       
        final Map<IndexField, String> map = new HashMap<IndexField, String>();


           map.put(IndexField.subject, StringUtils.trimToEmpty( object.getName())); 
           map.put(IndexField.objectID, String.valueOf(object.getID()));
           map.put(IndexField.objectType, String.valueOf(object.getObjectType()));
           map.put(IndexField.creationDate, String.valueOf(object.getCreationDate().getTime()));
           map.put(IndexField.modificationDate, String.valueOf(object.getModificationDate().getTime()));
           map.put(IndexField.userID, String.valueOf(citation.getEnterBy().getID()))


        return map;
      }


}


To register my object Type I have an sbs-ext.xml




<sbs-ext>
    <objectType beanId="myObjectType">
        <entitlements provider="MyEntitlementCheckProvider" parent="baseEntitlementProvider">
            <level name="Create"
                   description="Allows users to create comment and view ">
                <associate level="Administer"/>
                <associate level="Moderate"/>
                <associate level="Create"/>
                <mask name="Create"/>
                <mask name="Comment/reply"/>
                <mask name="Read"/>
                <mask name="Insert image"/>
            </level>
            <level name="Contribute" description="Allows users to comment on and view ">
                <associate level="Contribute"/>
                <mask name="Comment/reply"/>
                <mask name="Read"/>
            </level>
            <level name="View" description="Allows users to view">
                <associate level="View"/>
                <mask name="Read"/>
            </level>
            <mask name="Create"/>
            <mask name="Comment/reply"/>
            <mask name="Read"/>
            <mask name="Insert image"/>
        </entitlements>
    </objectType>
</sbs-ext>

 

 

on my manager class i fire an event after I save the content to the database .. just want to the note that

wfor the jivecontainerid and containerType.. I used the root community.. (containerID=1,containerType=14)

 

 protected void fireObjectAdded(MyObject object) {
         Future<MyObjectEvent> f = eventDispatcher.fireAndWait(new MyObjectEvent(MyObjectEvent.Type.CREATED, new ContainerAwareEntityDescriptor(object.getObjectType(), 
                    object.getID(), object.getJiveContainer().getID(), object.getJiveContainer().getObjectType()), 
                    object.getUser().getID()));
        
         try {
             f.get();
         } catch (ExecutionException e) {
             log.error("Could not fire added event for video " + object.getID(), e);
         } catch (InterruptedException e) {
             log.error("Could not fire added event for video " + object.getID(), e);
         }
    }

 

 

Thanks for your help!



Hi Michelle-

 

The biggest thing I noticed here was that IndexableType wasn't implemented. I thought FilteredIndexableType could be used to whittle down search results AFTER they've shown up in search results.

 

Of course, FilteredIndexableType extends IndexableType so it shouldn't be an issue but it might be something to try.

 

Ensure that your provider class has a method that will allow Spring to inject an instance of your object's manager class.

 

I am trying to see whether a type that doesn't "live" in a container will still show up in searches. I don't think it matters but I want to confirm that.

 

Can you at least vreate/delete/view instances of your type? And do your SQL statements look OK?

 

-gabe



Hi Gabe

 

Thanks for your respond..

 

Yes I am able to create, view and delete of my content type..

 

I want to note that..

 

I am integrating our old code (we used to overlay)  to the content type plugin.. and somewhat maybe not be following all content type code

I was wondering if this would take a big effect on searching or other things..

 

 

I also get different problems on different functionality that I want .. when I dont have the jivecontainerID and jivecontainerType

 

Would I be able to use the root containerID=1 , containerType =14

on anything features i want for example..

 

Recent Content ( problem here, where its trying to update get community content)

Recent History

Bookmark    (problem here , jiveobject is null and container problem)

Latest Content

Comments  .. ( no containerid and containertype)

and more...

 

Would this class effect my search? if I am not loading it right?

public class MyObjectFactory implements JiveObjectFactory<MyObject>, BlockObjectFactory<MyObject> {
}

 


Thanks!



Gabe, is the Memo Content Type plug-in held in the SVN repository compatible with SBS 4.x?

I've seen a reference to an updated plug-in that uses Maven, which we do not use. Is there a 4.x version that uses ANT?

 

Thanks,

 

John



Hi John,

 

I've seen a reference to an updated plug-in that uses Maven, which we do not use. Is there a 4.x version that uses ANT?

 

The only version that exists is the one in the public SVN.

 

Thanks,

Vinh


Outcomes