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


        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

        //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

                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
                    deleteCount += 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);
                }
View Full Code Here

            int count = Math.min(topHitsCount, topDocs.totalHits);
            List<ParsedObject> resultList = new ArrayList<ParsedObject>(count);
           
            for (int i = 0; i < count; i++)
            {
                ParsedObject result = new BaseParsedObject();
               
              Document doc = searcher.doc(topDocs.scoreDocs[i].doc);
         
            addFieldsToParsedObject(doc, result);
           
            result.setScore(topDocs.scoreDocs[i].score);
            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);
            }
           
View Full Code Here

                    log.error("Failed to create hanlder for object " + o.getClass().getName());
                    continue;
                }
   
                // Parse the object
                ParsedObject parsedObject = handler.parseObject(o);
               
                String key = parsedObject.getKey();
                // if there's an existing one with the same key, then remove it first.
                if (parsedObject.getKey() != null)
                {
                    Term keyTerm = new Term(ParsedObject.FIELDNAME_KEY, key);
                    TopDocs topDocs = searcher.search(new TermQuery(keyTerm), 1);
                    if (topDocs.totalHits > 0)
                    {
                        indexWriter.deleteDocuments(keyTerm);
                    }
                }
               
                String type = parsedObject.getType();
                String title = parsedObject.getTitle();
                String description = parsedObject.getDescription();
                String content = parsedObject.getContent();
                String language = parsedObject.getLanguage();
                URL url = parsedObject.getURL();
                String className = parsedObject.getClassName();
               
                // Create document
                Document doc = new Document();
               
                // Populate document from the parsed object
                if (key != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_KEY, key, Field.Store.YES, Field.Index.NOT_ANALYZED));
                }
                if (type != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_TYPE, type, Field.Store.YES, Field.Index.ANALYZED));
                }
                if (title != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_TITLE, title, Field.Store.YES, Field.Index.ANALYZED));
                }
                if (description != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_DESCRIPTION, description, Field.Store.YES, Field.Index.ANALYZED));
                }
                if (content != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_CONTENT, content, Field.Store.NO, Field.Index.ANALYZED));
                }
                if (language != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_LANGUAGE, language, Field.Store.YES, Field.Index.ANALYZED));
                }
                if (url != null)
                {
                    String urlString = url.toString();
                    doc.add(new Field(ParsedObject.FIELDNAME_URL, urlString, Field.Store.YES, Field.Index.ANALYZED));
                }
                if (className != null)
                {
                    doc.add(new Field(ParsedObject.FIELDNAME_CLASSNAME, className, Field.Store.YES, Field.Index.ANALYZED));
                }
               
                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.NOT_ANALYZED));
                    }
                }
   
                Map keywords = parsedObject.getKeywordsMap();
                addFieldsToDocument(doc, keywords, KEYWORD);
               
                Map fields = parsedObject.getFields();
                addFieldsToDocument(doc, fields, TEXT);
               
                List<String> syntheticField = new ArrayList<String>();
                for (Fieldable fieldable : doc.getFields())
                {
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);

                if (parsedObject.getKey() != null)
                {
                    String queryString = new StringBuilder(40).append(ParsedObject.FIELDNAME_KEY).append(':').append(ClientUtils.escapeQueryChars(parsedObject.getKey())).toString();
                   
                    SolrQuery query = new SolrQuery();
                    query.setQuery(queryString);
                    QueryResponse qrsp = server.query(query);
                    int count = qrsp.getResults().size();
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.