Package org.apache.jetspeed.search

Examples of org.apache.jetspeed.search.SearchResults


    public void testVerifyJetspeedSearch1() throws Exception
    {
//      because tear down deletes files, need to do add again
        testPutWebPage();
       
        SearchResults results  = searchEngine.search("Jetspeed");
        assertTrue(" Hit count == 0", results.size() > 0);
       
        Iterator resultIter = results.iterator();
        while (resultIter.hasNext())
        {
            ParsedObject result = (ParsedObject) resultIter.next();
            System.out.println("Score = " + result.getScore());
            System.out.println("title = " + result.getTitle());
View Full Code Here


    public void testVerifyJetspeedSearch2() throws Exception
    {
//      because tear down deletes files, need to do add again
        testPutWebPage();
       
        SearchResults results  = searchEngine.search("community");
        assertTrue(" Hit count == 0", results.size() > 0);
       
        Iterator resultIter = results.iterator();
        while (resultIter.hasNext())
        {
            ParsedObject result = (ParsedObject) resultIter.next();
            System.out.println("Score = " + result.getScore());
            System.out.println("title = " + result.getTitle());
View Full Code Here

            {
                //logger.error("Closing Searcher", ioe);
            }
        }
       
        SearchResults results = new SearchResultsImpl(resultList);
        return results;
    }
View Full Code Here

    if(control != null)
    {
        String searchString = actionRequest.getParameter("query");
        if(searchString != null)
        {
            SearchResults results = searchEngine.search(searchString);
            actionRequest.getPortletSession().setAttribute("search_results", results.getResults());
        }
       
      String node = actionRequest.getParameter("node");
      if(node != null)
      {
View Full Code Here

//          Query query = QueryParser.parse(searchString, ParsedObject.FIELDNAME_CONTENT, analyzer);
        }
        catch (ParseException e)
        {
            List<ParsedObject> resultList = new ArrayList<ParsedObject>();
            SearchResults results = new SearchResultsImpl(resultList);
            return results;           
        }
       
        try
        {
            hits = searcher.search(query);
        }
        catch (IOException e)
        {
            List<ParsedObject> resultList = new ArrayList<ParsedObject>();
            SearchResults results = new SearchResultsImpl(resultList);
            return results;           
        }

        int hitNum = hits.length();
        List<ParsedObject> resultList = new ArrayList<ParsedObject>(hitNum);
        for(int i=0; i<hitNum; i++)
        {
            ParsedObject result = new BaseParsedObject();
            try
            {
              Document doc = hits.doc(i);
         
            addFieldsToParsedObject(doc, result);
           
            result.setScore(hits.score(i));
            Field type = doc.getField(ParsedObject.FIELDNAME_TYPE);
            if(type != null)
            {
                result.setType(type.stringValue());
            }
           
            Field key = doc.getField(ParsedObject.FIELDNAME_KEY);
            if(key != null)
            {
                result.setKey(key.stringValue());
            }
           
            Field description = doc.getField(ParsedObject.FIELDNAME_DESCRIPTION);
            if(description != null)
            {
                result.setDescription(description.stringValue());
            }
           
            Field title = doc.getField(ParsedObject.FIELDNAME_TITLE);
            if(title != null)
            {
                result.setTitle(title.stringValue());
            }
           
            Field content = doc.getField(ParsedObject.FIELDNAME_CONTENT);
            if(content != null)
            {
                result.setContent(content.stringValue());
            }
           
            Field language = doc.getField(ParsedObject.FIELDNAME_LANGUAGE);
            if (language != null)
            {
              result.setLanguage(language.stringValue());
            }
           
            Field classname = doc.getField(ParsedObject.FIELDNAME_CLASSNAME);
            if (classname != null)
            {
              result.setClassName(classname.stringValue());
            }
           
            Field url = doc.getField(ParsedObject.FIELDNAME_URL);
            if (url != null)
            {
                result.setURL(new URL(url.stringValue()));
            }
           
            Field[] keywords = doc.getFields(ParsedObject.FIELDNAME_KEYWORDS);
            if(keywords != null)
            {
              String[] keywordArray = new String[keywords.length];
             
              for(int j=0; j<keywords.length; j++)
              {
                Field keyword = keywords[j];
                keywordArray[j] = keyword.stringValue();
              }
             
              result.setKeywords(keywordArray);
            }
           
            resultList.add(i, result);
            }
            catch(IOException e)
            {
                //logger
            }
        }

        if (searcher != null)
        {
            try
            {
                searcher.close();
            }
            catch (IOException ioe)
            {
                //logger.error("Closing Searcher", ioe);
            }
        }
       
        SearchResults results = new SearchResultsImpl(resultList);
        return results;
    }
View Full Code Here

    public void testVerifyJetspeedSearch() throws Exception
    {
        //because tear down deletes files, need to do add again
        testPutWebPage();
       
        SearchResults results  = searchEngine.search("YourResultsBelongToUs");
        //System.out.println("Query 'YourResultsBelongToUs' hits = " + results.size());
        assertTrue(" Hit count == 0", results.size() == 0);
        Iterator resultIter = results.iterator();
        while (resultIter.hasNext())
        {
            ParsedObject result = (ParsedObject) resultIter.next();
           
            System.out.println("Score = " + result.getScore());
View Full Code Here

    public void testVerifyJetspeedSearch1() throws Exception
    {
//      because tear down deletes files, need to do add again
        testPutWebPage();
       
        SearchResults results  = searchEngine.search("Jetspeed");
        assertTrue(" Hit count == 0", results.size() > 0);
       
        Iterator resultIter = results.iterator();
        while (resultIter.hasNext())
        {
            ParsedObject result = (ParsedObject) resultIter.next();
            System.out.println("Score = " + result.getScore());
            System.out.println("title = " + result.getTitle());
View Full Code Here

    public void testVerifyJetspeedSearch2() throws Exception
    {
//      because tear down deletes files, need to do add again
        testPutWebPage();
       
        SearchResults results  = searchEngine.search("community");
        assertTrue(" Hit count == 0", results.size() > 0);
       
        Iterator resultIter = results.iterator();
        while (resultIter.hasNext())
        {
            ParsedObject result = (ParsedObject) resultIter.next();
            System.out.println("Score = " + result.getScore());
            System.out.println("title = " + result.getTitle());
View Full Code Here

       
        if (!StringUtils.isBlank(queryParam))
        {
            String queryText =
                ParsedObject.FIELDNAME_TYPE + ":\"" + ParsedObject.OBJECT_TYPE_PORTLET_APPLICATION + "\" AND ( " + queryParam + " )";
            SearchResults searchResults = searchEngine.search(queryText);
            List<ParsedObject> searchResultList = searchResults.getResults();
            paBeans.setTotalSize(searchResultList.size());
           
            for (ParsedObject parsedObject : (List<ParsedObject>) PaginationUtils.subList(searchResultList, beginIndex, maxResults))
            {
                String appName = SearchEngineUtils.getFieldAsString(parsedObject, "ID", null);
View Full Code Here

        {
            String queryText =
                ParsedObject.FIELDNAME_TYPE + ":\"" + ParsedObject.OBJECT_TYPE_PORTLET + "\" " +
                "AND NOT " + ParsedObject.FIELDNAME_TYPE + ":\"" + ParsedObject.OBJECT_TYPE_PORTLET_APPLICATION + "\" " +
                "AND ( " + (!StringUtils.isBlank(keywordsParam) ? keywordsParam : queryParam) + " )";
            SearchResults searchResults = null;
           
            if (!StringUtils.isBlank(keywordsParam))
            {
                searchResults = searchEngine.search(queryText, ParsedObject.FIELDNAME_KEYWORDS);
            }
            else
            {
                searchResults = searchEngine.search(queryText);
            }
           
            List<ParsedObject> searchResultList = searchResults.getResults();
            ArrayList<PortletDefinition> searchedPortletDefinitions = new ArrayList<PortletDefinition>();
           
            for (ParsedObject parsedObject : searchResultList)
            {
                String uniqueName = SearchEngineUtils.getPortletUniqueName(parsedObject);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.search.SearchResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.