Package net.fp.rp.search.back.search

Examples of net.fp.rp.search.back.search.SearchQuery


                    //ignore the terms (conjuction:AND, OR) )
                    if ((!term.equalsIgnoreCase("and")) &&
                            (!term.equalsIgnoreCase("or"))) {
                        //construct the search query for the term
                        SearchQuery queryForm = new SearchQuery(term);

                        //for all the plugins invoke the search process
                        for (int i = 0; i < plugins.length; i++) {
                            //find the documents that contain the specified token ordered by direct score
                            plugins[i].doSearch(queryForm,
View Full Code Here


                }
            }

            IInterestedInSearch[] plugins = PluginManager.getInterestedInSearch();
            log.debug("Number of plugins able to carry out search:"+plugins.length);
            SearchQuery query = new SearchQuery(somethingToSearch);

            //do the search
            for (int i = 0; i < plugins.length; i++) {
                plugins[i].doSearch(query, DocumStruct.FIELD_SORT_SCORE, true,
                    searchCount,useThreading);
            }

            //wait till all the search plugins are done or time out was reached
            if(useThreading){
               boolean wait = true;
                 log.debug(
                     "Wait for plugin to finish the search operation (plugins are ready or time expired)");

                 while (wait && !Util.isTimeExpired(start, maxWaitSearchTime)) {
                     wait = false;

                     for (int i = 0; i < plugins.length; i++) {
                         if (!plugins[i].isReady()) {
                             wait = true;
                         }
                     }
                 }
            }
          

            //iterate on the plugins and gather the result:startno,endno,list of documents found it, search query)
            int countErrors = 0;
            int countHits = 0;
            List allDocs = new ArrayList();

            for (int i = 0; i < plugins.length; i++) {
                ISearchResult result = plugins[i].getResults();
                countHits = countHits + result.getCountFound();
                countErrors = countErrors + result.getCountErrors();
                allDocs.addAll(result.getDocuments());
            }

            if (allDocs.size() > 0) {
                //we found documents (maybe with errors
                myModel.put(ModelView.STARTNO, "1");
                myModel.put(ModelView.ENDNO, String.valueOf(allDocs.size()));
                myModel.put(ModelView.DOCUMENTSNO,
                    String.valueOf(allDocs.size()));
                myModel.put(ModelView.DOCUMENTS, allDocs);
                myModel.put(ModelView.ERROR, "false");

                float elapsedTimeMillis = (System.currentTimeMillis() - start) / 1000F;
                myModel.put(ModelView.SEARCHTIME,
                    String.valueOf(elapsedTimeMillis));

                if (countErrors == 0) {
                    myModel.put(ModelView.STATUS,
                        MessageUtil.getMessage("app.search.status.noerror"));
                } else {
                    myModel.put(ModelView.STATUS,
                        MessageUtil.getMessage("app.search.status.errors",
                            new Object[] { String.valueOf(countErrors) }));
                }
            } else {
                //no document was found it
                log.debug("No pages were found containing " +
                    query.getQuery());
                myModel.put(ModelView.ERROR, "true");
                myModel.put(ModelView.STATUS,
                    MessageUtil.getMessage("app.search.status.nopage",
                        new Object[] { query.getQuery() }));
            }
        } catch (RpException e) {
            log.warn("Exception in search " + e.getMessage(), e);

            myModel.put(ModelView.ERROR, "true");
View Full Code Here

TOP

Related Classes of net.fp.rp.search.back.search.SearchQuery

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.