Package org.apache.lucene.search

Examples of org.apache.lucene.search.Hits


            searcher = new IndexSearcher(idxFilePath);
            Term instIdTerm = new Term("workflow_inst_status", status);
            org.apache.lucene.search.Query query = new TermQuery(instIdTerm);
            Sort sort = new Sort(new SortField("workflow_inst_startdatetime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            numInsts = hits.length();

        } catch (IOException e) {
            LOG.log(Level.WARNING,
                    "IOException when opening index directory: [" + idxFilePath
                            + "] for search: Message: " + e.getMessage());
View Full Code Here


        try {
            searcher = new IndexSearcher(idxFilePath);
            Term instIdTerm = new Term("workflow_inst_id", workflowInstId);
            org.apache.lucene.search.Query query = new TermQuery(instIdTerm);
            Hits hits = searcher.search(query);

            if (hits.length() != 1) {
                LOG.log(Level.WARNING, "The workflow instance: ["
                        + workflowInstId + "] is not being "
                        + "managed by this " + "workflow engine, or "
                        + "is not unique in the catalog!");
                return null;
            } else {
                Document instDoc = hits.doc(0);
                wInst = toWorkflowInstance(instDoc);
            }

        } catch (IOException e) {
            LOG.log(Level.WARNING,
View Full Code Here

            searcher = new IndexSearcher(idxFilePath);
            Term instIdTerm = new Term("myfield", "myvalue");
            org.apache.lucene.search.Query query = new TermQuery(instIdTerm);
            Sort sort = new Sort(new SortField("workflow_inst_startdatetime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            if (hits.length() > 0) {
                wInsts = new Vector(hits.length());

                for (int i = 0; i < hits.length(); i++) {
                    Document doc = hits.doc(i);
                    WorkflowInstance wInst = toWorkflowInstance(doc);
                    wInsts.add(wInst);
                }
            }
View Full Code Here

            searcher = new IndexSearcher(idxFilePath);
            Term instIdTerm = new Term("workflow_inst_status", status);
            org.apache.lucene.search.Query query = new TermQuery(instIdTerm);
            Sort sort = new Sort(new SortField("workflow_inst_startdatetime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            if (hits.length() > 0) {
                wInsts = new Vector(hits.length());

                for (int i = 0; i < hits.length(); i++) {
                    Document doc = hits.doc(i);
                    WorkflowInstance wInst = toWorkflowInstance(doc);
                    wInsts.add(wInst);
                }
            }
View Full Code Here

            Sort sort = new Sort(new SortField("workflow_inst_startdatetime",
                    SortField.STRING, true));
            LOG.log(Level.FINE,
                    "Querying LuceneWorkflowInstanceRepository: q: ["
                            + booleanQuery + "]");
            Hits hits = searcher.search(booleanQuery, sort);
            if (hits.length() > 0) {

                int startNum = (pageNum - 1) * pageSize;
                if (startNum > hits.length()) {
                    startNum = 0;
                }

                instIds = new Vector(pageSize);

                for (int i = startNum; i < Math.min(hits.length(),
                        (startNum + pageSize)); i++) {
                    Document instDoc = hits.doc(i);
                    WorkflowInstance inst = toWorkflowInstance(instDoc);
                    instIds.add(inst.getId());

                }
            } else {
View Full Code Here

        IndexSearcher searcher = null;
        try {
            searcher = new IndexSearcher(indexFilePath);
            Term productIdTerm = new Term("product_id", productId);
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Hits hits = searcher.search(query);

            // should be exactly 1 hit
            if (hits.length() != 1) {
                throw new CatalogException("Product: [" + productId
                        + "] is not unique in the catalog!");
            }

            Document productDoc = hits.doc(0);
            CompleteProduct prod = toCompleteProduct(productDoc, getRefs,
                    getMet);
            return prod;
        } catch (IOException e) {
            LOG.log(Level.WARNING,
View Full Code Here

            searcher = new IndexSearcher(indexFilePath);
            Term productIdTerm = new Term("product_name", productName);
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            // should be > 0 hits
            if (hits.length() > 0) {
                // just get the first hit back
                Document productDoc = hits.doc(0);
                CompleteProduct prod = toCompleteProduct(productDoc, getRefs,
                        false);
                return prod.getProduct();
            } else {
                LOG.log(Level.FINEST, "Request for product by name: ["
View Full Code Here

            searcher = new IndexSearcher(indexFilePath);
            Term productIdTerm = new Term("myfield", "myvalue");
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            // should be > 0 hits
            if (hits.length() > 0) {
                products = new Vector<Product>(hits.length());
                for (int i = 0; i < hits.length(); i++) {
                    Document productDoc = hits.doc(i);
                    CompleteProduct prod = toCompleteProduct(productDoc,
                            getRefs, false);
                    products.add(prod.getProduct());
                }
            } else {
View Full Code Here

            Term productIdTerm = new Term("product_type_id", type
                    .getProductTypeId());
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Sort sort = new Sort(new SortField("CAS.ProductReceivedTime",
                    SortField.STRING, true));
            Hits hits = searcher.search(query, sort);

            // should be > 0 hits
            if (hits.length() > 0) {
                products = new Vector<Product>(hits.length());
                for (int i = 0; i < hits.length(); i++) {
                    Document productDoc = hits.doc(i);
                    CompleteProduct prod = toCompleteProduct(productDoc,
                            getRefs, false);
                    products.add(prod.getProduct());
                }
            } else {
View Full Code Here

        IndexSearcher searcher = null;
        try {
            searcher = new IndexSearcher(indexFilePath);
            Term productIdTerm = new Term("product_id", product.getProductId());
            org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
            Hits hits = searcher.search(query);

            // should be exactly 1 hit
            if (hits.length() != 1) {
                throw new CatalogException("Product: ["
                        + product.getProductId()
                        + "] is not unique in the catalog! Num Hits: ["
                        + hits.length() + "]");
            }

            Document productDoc = hits.doc(0);
            CompleteProduct prod = toCompleteProduct(productDoc, false, true);
            return prod.getMetadata();
        } catch (IOException e) {
            LOG.log(Level.WARNING,
                    "IOException when opening index directory: ["
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.Hits

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.