Search in sources :

Example 6 with SearchBean

use of org.apache.cxf.jaxrs.ext.search.SearchBean in project cxf by apache.

the class TikaContentExtractorTest method testExtractedTextContentDoesNotMatchSearchCriteria.

@Test
public void testExtractedTextContentDoesNotMatchSearchCriteria() throws Exception {
    SearchCondition<SearchBean> sc = parser.parse("Author==Barry*");
    final SearchBean bean = extractor.extractMetadataToSearchBean(getClass().getResourceAsStream("/files/testPDF.pdf"));
    assertNotNull("Document should not be null", bean);
    assertFalse(sc.isMet(bean));
}
Also used : SearchBean(org.apache.cxf.jaxrs.ext.search.SearchBean) Test(org.junit.Test)

Example 7 with SearchBean

use of org.apache.cxf.jaxrs.ext.search.SearchBean in project cxf by apache.

the class TikaLuceneContentExtractorTest method getHits.

private ScoreDoc[] getHits(final String expression, final Map<String, Class<?>> fieldTypes) throws IOException {
    IndexReader reader = DirectoryReader.open(directory);
    IndexSearcher searcher = new IndexSearcher(reader);
    try {
        LuceneQueryVisitor<SearchBean> visitor = new LuceneQueryVisitor<SearchBean>("ct", "contents");
        visitor.setPrimitiveFieldTypeMap(fieldTypes);
        visitor.visit(parser.parse(expression));
        ScoreDoc[] hits = searcher.search(visitor.getQuery(), null, 1000).scoreDocs;
        assertNotNull(hits);
        return hits;
    } finally {
        reader.close();
    }
}
Also used : IndexSearcher(org.apache.lucene.search.IndexSearcher) IndexReader(org.apache.lucene.index.IndexReader) SearchBean(org.apache.cxf.jaxrs.ext.search.SearchBean) LuceneQueryVisitor(org.apache.cxf.jaxrs.ext.search.lucene.LuceneQueryVisitor) ScoreDoc(org.apache.lucene.search.ScoreDoc)

Example 8 with SearchBean

use of org.apache.cxf.jaxrs.ext.search.SearchBean in project cxf by apache.

the class TikaLuceneContentExtractorTest method setUp.

@Before
public void setUp() throws Exception {
    final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9);
    directory = new RAMDirectory();
    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
    writer = new IndexWriter(directory, config);
    writer.commit();
    parser = new FiqlParser<SearchBean>(SearchBean.class);
    extractor = new TikaLuceneContentExtractor(new PDFParser());
}
Also used : IndexWriter(org.apache.lucene.index.IndexWriter) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) PDFParser(org.apache.tika.parser.pdf.PDFParser) SearchBean(org.apache.cxf.jaxrs.ext.search.SearchBean) Analyzer(org.apache.lucene.analysis.Analyzer) StandardAnalyzer(org.apache.lucene.analysis.standard.StandardAnalyzer) RAMDirectory(org.apache.lucene.store.RAMDirectory) IndexWriterConfig(org.apache.lucene.index.IndexWriterConfig) Before(org.junit.Before)

Aggregations

SearchBean (org.apache.cxf.jaxrs.ext.search.SearchBean)8 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 ExceptionMapper (javax.ws.rs.ext.ExceptionMapper)1 Bus (org.apache.cxf.Bus)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1 Interceptor (org.apache.cxf.interceptor.Interceptor)1 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)1 ResponseExceptionMapper (org.apache.cxf.jaxrs.client.ResponseExceptionMapper)1 QueryContextProvider (org.apache.cxf.jaxrs.ext.search.QueryContextProvider)1 SearchContextProvider (org.apache.cxf.jaxrs.ext.search.SearchContextProvider)1 LuceneQueryVisitor (org.apache.cxf.jaxrs.ext.search.lucene.LuceneQueryVisitor)1 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)1 BinaryDataProvider (org.apache.cxf.jaxrs.provider.BinaryDataProvider)1 JAXBElementProvider (org.apache.cxf.jaxrs.provider.JAXBElementProvider)1 Message (org.apache.cxf.message.Message)1