Skip to Content
author's profile photo Former Member
Former Member

Searching with TREX

Hi all,

I am making a custom iView that perform search with TREX. At the time I want to add selection criteria on properties name, description, last modified etc. I don't know how to add such property in code. What property name and namespace should I use. Do any one have experience or code sample about that? I searched over the SDN and JavaDoc, but no related info talking about the property.



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 11:40 AM

    Hi Sam,

    if you whant to search into a property value, like those described by you, you need to create a new query entry for everyone of the property you'd like to include into your search request. For example you have to create a query entry like this one:

    IQueryEntry qe = federatedSearch.getNewQueryEntry();

    PropertyName propName = null;

    try {

    propName = new PropertyName(<property namespace>, <property id>);



    qe.setValue(<property value>);


    qe.setPropertyType(<property type for example a date> IQueryEntry.PROPERTY_TYPE_STRING);


    } catch (WcmException e) {


    so you have to determine the property namespace and property id of the property to include into the search request. In order to do that you can, for example, use the "property metadata service" you can find under KM configuration.

    After you have create all your query entry you need to "join" them using the search operators (AND, OR, ...)

    a search operator is built as a query entry as well, below an example:

    IQueryEntry oper = federatedSearch.getNewQueryEntry();

    try {


    oper.setValue(<operator type for example AND>IQueryEntry.OPERATOR_AND);

    } catch (WcmException e) {


    You should have also a query entry which represent the search string, for example:

    IQueryEntry text = federatedSearch.getNewQueryEntry();

    try {




    text.setValue((String) currentHM.get(currentKey));

    } catch (WcmException e) {


    After that put all your query entries into a QueryEntryList, for example:

    IFederatedSearch federatedSearch = (IFederatedSearch) indexService.getObjectInstance(IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);

    IQueryEntryList qel = federatedSearch.getNewQueryEntryList();

    //pay attention to add into the qel the query entry in the right order




    //and then perform a search with this query entry list, for example

    ISearchSession ss = federatedSearch.searchWithSession(qel, (ICollection) folderRes, resourceContext);

    with this query entry list you search the provided query string into documents name, documents description (by default) AND into for example a your own predefined property of type string.

    Hope this help. If you need more info let me know.



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Roberto,

      Thanks for your solution. I can found the location where maintain the properties. In EP5, the location is "KM Admin > Configuration > Content Management > Global Services > Property Metadata > Properties".

      And now I can find the property ID that I needed.

      Thanks a lot


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.