0 Replies Latest reply on Jul 13, 2007 9:36 AM by 441615

    UltraSearch API : Document.getUrl() : returns URL of Portal Items, not Page

    441615
      Hi,

      I am new to UltraSearch & I have managed to set up an instance, define the Sources and define a Scheduler to search the Sources. I am trying to build an application that uses the UltraSearch APIs to connect to the Instance & retrieve the Search Results.

      I am using Oracle UltraSearch 10.1.4.0.2. I have set up an UltraSearch Source to crawl through the Public Pages in my Oracle Portal Instance.

      Here's the code snippet that I use :-
      public ArrayList getSearchResults(String strKeyword)
        {
           String strMethodName = "getSearchResults";
           
           ArrayList alSearchResults = new ArrayList();
          
           Instance         objUltraSerachInstance      = null;
           InstanceMetaData objInstanceMetaData         = null;
           Query            objQuery                    = null;
           Result           objResult                   = null;
           Document         objDocument                 = null;
          
           UltraSearchResultsBean objUltraSearchResultsBean = null;
          
           Log.info(" Ultra "+":"+strClassName+":"+strMethodName+" Entering the Method ");
          
          
           strKeyword = strKeyword == null ? "" :strKeyword;
          
           try
           {
            objUltraSerachInstance = new Instance();
           
            objUltraSerachInstance.setConnection(objConnection);
            objUltraSerachInstance.setCloseConnection(false) ;
            //objUltraSerachInstance.setInstanceName("ULTRA_SEARCH");
            objUltraSerachInstance.setInstanceName("PORTALSITESEARCH");
                 
            objInstanceMetaData = objUltraSerachInstance.getMetaData();
           
            objQuery  = new Contains(strKeyword, objInstanceMetaData);
            objResult  = objUltraSerachInstance.getResult(objQuery, Locale.ENGLISH, 1, 10, null, null, null, true);
           
            for(Iterator iterator = objResult.iterator(); iterator.hasNext();)
            {
                objUltraSearchResultsBean = new UltraSearchResultsBean();
               
                objDocument = (Document)iterator.next();
               
                objUltraSearchResultsBean.setId( objDocument.getId() );
                objUltraSearchResultsBean.setScore( objDocument.getScore());
                objUltraSearchResultsBean.setUrl( objDocument.getUrl() );
                objUltraSearchResultsBean.setLastModified( objDocument.getLastModified() );
                objUltraSearchResultsBean.setExcerpt( objDocument.getExcerpt() );
               
                alSearchResults.add(objUltraSearchResultsBean);
            }
          
           Log.info("  Ultra "+":"+strClassName+":"+strMethodName+" alSearchResults "+alSearchResults);
           
           }
           catch (Exception objException)
           {
              Log.severe("  Ultra  "+":"+strClassName+":"+strMethodName+" Exception :: ",objException);
              objException.printStackTrace();
           }
           finally
           {
              cleanResources();
           }
          
           Log.info("  Ultra  "+":"+strClassName+":"+strMethodName+" Leaving the Method ");
          
           return alSearchResults;
        }
      I have a problem with this code - the getUrl() method returns the URLs of the Text Items in Portal, but not the Portal Page URL itself. As a result, when the user clicks on the HyperLinked URL, the Text item is shown out of context of the Page that contains it.

      I have even tried to limit the Crawler depth in an attempt to control this, but I am unable to do so.

      Can anyone please help me with this ? Is there a way to limit the search in UltraSearch to the Portal Page Level, instead of the Item Level ?

      Our Client wants to leverage UltraSearch with Portal & we have had successes with Oracle Database Tables. We are now facing a problem with only the Portal Pages.

      Our Application will ultimately be converted into a reusable J-PDK Portlet.

      Please do let me know if I need to include any other information.

      Regards,
      Sandeep Seshan