Package org.apache.jetspeed.search

Examples of org.apache.jetspeed.search.ParsedObject


        //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());
            System.out.println("title = " + result.getTitle());
            System.out.println("summary = " + result.getDescription());
            System.out.println("url = " + result.getURL());
        }
    }
View Full Code Here


                //logger.error("Failed to create hanlder for object " + o.getClass().getName());
                continue;
            }

            // Parse the object
            ParsedObject parsedObject = handler.parseObject(o);

            // Create document
            Document doc = new Document();

            // Populate document from the parsed object
            if (parsedObject.getKey() != null)
            {
                doc.add(Field.Keyword(ParsedObject.FIELDNAME_KEY, parsedObject.getKey()));
            }
            if (parsedObject.getType() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_TYPE, parsedObject.getType()));
            }
            if (parsedObject.getTitle() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_TITLE, parsedObject.getTitle()));
            }
            if (parsedObject.getDescription() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_DESCRIPTION, parsedObject.getDescription()));
            }
            if (parsedObject.getContent() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_CONTENT, parsedObject.getContent()));
            }
            if (parsedObject.getLanguage() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_LANGUAGE, parsedObject.getLanguage()));  
            }
            if (parsedObject.getURL() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_URL, parsedObject.getURL().toString()));
            }
            if(parsedObject.getClassName() != null)
            {
                doc.add(Field.Text(ParsedObject.FIELDNAME_CLASSNAME, parsedObject.getClassName()));
            }
           
            String[] keywordArray = parsedObject.getKeywords();
            if(keywordArray != null)
            {
              for(int i=0; i<keywordArray.length; ++i)
              {
                String keyword = keywordArray[i];
                doc.add(Field.Keyword(ParsedObject.FIELDNAME_KEYWORDS, keyword));
              }
            }

            Map keywords = parsedObject.getKeywordsMap();
            addFieldsToDocument(doc, keywords, KEYWORD);
           
            Map fields = parsedObject.getFields();
            addFieldsToDocument(doc, fields, TEXT);
            // Add the document to search index
            try
            {
View Full Code Here

                Object o = it.next();
                // Look up appropriate handler
                ObjectHandler handler = handlerFactory.getHandler(o);

                // Parse the object
                ParsedObject parsedObject = handler.parseObject(o);

                // Create term
                Term term = null;

                if (parsedObject.getKey() != null)
                {
                    term = new Term(ParsedObject.FIELDNAME_KEY, parsedObject.getKey());
                    // Remove the document from search index
                    int rc = indexReader.delete(term);
                    //logger.info("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
                    //System.out.println("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
                    result = rc > 0;
View Full Code Here

        int hitNum = hits.length();
        ArrayList resultList = new ArrayList(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)
View Full Code Here

                //logger.error("Failed to create hanlder for object " + o.getClass().getName());
                continue;
            }

            // Parse the object
            ParsedObject parsedObject = handler.parseObject(o);

            // Create document
            Document doc = new Document();

            // Populate document from the parsed object
            if (parsedObject.getKey() != null)
            {               
                doc.add(new Field(ParsedObject.FIELDNAME_KEY, parsedObject.getKey(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            }
            if (parsedObject.getType() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_TYPE, parsedObject.getType(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if (parsedObject.getTitle() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_TITLE, parsedObject.getTitle(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if (parsedObject.getDescription() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_DESCRIPTION, parsedObject.getDescription(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if (parsedObject.getContent() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_CONTENT, parsedObject.getContent(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if (parsedObject.getLanguage() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_LANGUAGE, parsedObject.getLanguage(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if (parsedObject.getURL() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_URL, parsedObject.getURL().toString(), Field.Store.YES, Field.Index.TOKENIZED));
            }
            if(parsedObject.getClassName() != null)
            {
                doc.add(new Field(ParsedObject.FIELDNAME_CLASSNAME, parsedObject.getClassName(), Field.Store.YES, Field.Index.TOKENIZED));
            }
           
            String[] keywordArray = parsedObject.getKeywords();
            if(keywordArray != null)
            {
              for(int i=0; i<keywordArray.length; ++i)
              {
                String keyword = keywordArray[i];
                doc.add(new Field(ParsedObject.FIELDNAME_KEYWORDS, keyword, Field.Store.YES, Field.Index.UN_TOKENIZED));
              }
            }

            Map keywords = parsedObject.getKeywordsMap();
            addFieldsToDocument(doc, keywords, KEYWORD);
           
            Map fields = parsedObject.getFields();
            addFieldsToDocument(doc, fields, TEXT);
            // Add the document to search index
            try
            {
View Full Code Here

                Object o = it.next();
                // Look up appropriate handler
                ObjectHandler handler = handlerFactory.getHandler(o);

                // Parse the object
                ParsedObject parsedObject = handler.parseObject(o);

                // Create term
                Term term = null;

                if (parsedObject.getKey() != null)
                {
                    term = new Term(ParsedObject.FIELDNAME_KEY, parsedObject.getKey());
                    // Remove the document from search index
                    int rc = indexReader.deleteDocuments(term);
                    //logger.info("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
                    //System.out.println("Attempted to delete '" + term.toString() + "' from index, documents deleted = " + rc);
                    result = rc > 0;
View Full Code Here

        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)
View Full Code Here

        //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());
            System.out.println("title = " + result.getTitle());
            System.out.println("summary = " + result.getDescription());
            System.out.println("url = " + result.getURL());
        }
    }
View Full Code Here

        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());
            System.out.println("summary = " + result.getDescription());
            System.out.println("url = " + result.getURL());
        }
    }
View Full Code Here

        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());
            System.out.println("summary = " + result.getDescription());
            System.out.println("url = " + result.getURL());
        }
    }
View Full Code Here

TOP

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

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.