Package org.apache.jena.larq

Examples of org.apache.jena.larq.IndexLARQ


        // ---- Finish indexing
        larqBuilder.closeWriter() ;
        model.unregister(larqBuilder) ;
       
        // ---- Create the access index 
        IndexLARQ index = larqBuilder.getIndex() ;
        return index ;
    }
View Full Code Here


        System.out.println("ARQ Example: "+Utils.classShortName(ExLucene2.class)) ;
        System.out.println("ARQ: "+ARQ.VERSION) ;
        System.out.println() ;
       
        Model model = ModelFactory.createDefaultModel() ;
        IndexLARQ index = ExLucene1.buildIndex(model,  "src/test/resources/LARQ/data-1.ttl") ;
       
        // Search for string
        String searchString = "+document" ;
       
        // This time, find documents with a matching DC title.
        String queryString = StrUtils.strjoin("\n",
            "PREFIX pf:     <http://jena.hpl.hp.com/ARQ/property#>",
            "PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>" ,
            "PREFIX dc:     <http://purl.org/dc/elements/1.1/>",
            "PREFIX :       <http://example/>" ,
            "SELECT ?doc ?title {" ,
            "    ?title pf:textMatch '"+searchString+"'.",
            "    ?doc   dc:title ?title",
            "}") ;
       
        // Two of three documents should match.
        ExLucene1.performQuery(model, index, queryString) ;
        index.close() ;
    }
View Full Code Here

        System.out.println("ARQ Example: "+Utils.classShortName(ExLucene4.class)) ;
        System.out.println("ARQ: "+ARQ.VERSION) ;
        System.out.println() ;
       
        Model model = ModelFactory.createDefaultModel() ;
        IndexLARQ index = buildSubjectTitleIndex(model,  "src/test/resources/LARQ/data-1.ttl") ;
       
        // Search for string
        String searchString = "+document" ;
       
        // This time, find documents with a matching DC title.
        String queryString = StrUtils.strjoin("\n",
            "PREFIX pf:     <http://jena.hpl.hp.com/ARQ/property#>",
            "PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>" ,
            "PREFIX dc:     <http://purl.org/dc/elements/1.1/>",
            "PREFIX :       <http://example/>" ,
            "SELECT ?doc {" ,
            "    ?doc pf:textMatch '"+searchString+"'.",
            "}") ;
       
        // Two of three documents should match.
        ExLucene1.performQuery(model, index, queryString) ;
        index.close() ;
    }
View Full Code Here

        // ---- Finish indexing
        larqBuilder.closeWriter() ;
        model.unregister(larqBuilder) ;
       
        // ---- Create the access index 
        IndexLARQ index = larqBuilder.getIndex() ;
        return index ;
    }
View Full Code Here

        System.out.println("ARQ: "+ARQ.VERSION) ;
        System.out.println() ;
       
        Model model = ModelFactory.createDefaultModel() ;

        IndexLARQ index = buildIndexExternalContent(model) ;
       
        // Search for string
        String searchString = "+document" ;
       
        // This time, find documents with a matching DC title.
        String queryString = StrUtils.strjoin("\n",
            "PREFIX pf:     <http://jena.hpl.hp.com/ARQ/property#>",
            "SELECT ?doc {" ,
            "    ?doc pf:textMatch '"+searchString+"'.",
            "}") ;
       
        // Two of three docuemnts should match.
        ExLucene1.performQuery(model, index, queryString) ;
        index.close() ;
    }
View Full Code Here

        // Note that the model is untouched - the index exists outside of any model statements.
        // The application is responsible for keeping
        // ----
       
        larqBuilder.closeWriter() ;
        IndexLARQ index = larqBuilder.getIndex() ;
       
//        NodeIterator iter = index.searchModelByIndex(model, "document") ;
//        for ( ; iter.hasNext() ; )
//            System.out.println("Found: "+FmtUtils.stringForRDFNode((RDFNode)iter.next())) ;
       
View Full Code Here

    public IndexLARQ getIndexLARQ()
    {
        try {
            FSDirectory dir = FSDirectory.open(luceneDir);
            IndexReader indexReader = IndexReader.open(dir) ;
            return new IndexLARQ(indexReader) ;
        } catch (Exception ex)
        { throw new ARQLuceneException("LARQ", ex) ; }
    }
View Full Code Here

            directory = FSDirectory.open(path);
        } else {
            directory = new RAMDirectory();
        }
        IndexReader indexReader = null;
        IndexLARQ indexLARQ = null;
        if ( dataset != null )
        {
            try
            {
                IndexWriter indexWriter = IndexWriterFactory.create(directory);
                IndexBuilderModel larqBuilder = new IndexBuilderString(indexWriter) ;
                dataset.getDefaultModel().register(larqBuilder);
                for ( Iterator<String> iter = dataset.listNames() ; iter.hasNext() ; ) {
                    String g = iter.next() ;
                    dataset.getNamedModel(g).register(larqBuilder) ;
                }
                indexLARQ = new IndexLARQ(indexWriter) ;
            } catch (LockObtainFailedException e) {
                log.warn("Someone else has a lock on the Lucene index, falling back to read-only mode.");
            }
        }
       
        if ( indexLARQ == null )
        {
            indexReader = IndexReader.open(directory) ; // read-only
            indexLARQ = new IndexLARQ(indexReader) ;
        }

        LARQ.setDefaultIndex(indexLARQ) ;
        return indexLARQ ;
    }
View Full Code Here

TOP

Related Classes of org.apache.jena.larq.IndexLARQ

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.