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));
}
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();
}
}
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());
}
Aggregations