Mustafa
Mustafa

Reputation: 10413

Usning Lucene Query to test if a document matches

I am using Lucene queries for a project like the following:

Analyzer analyzer = new StandardAnalyzer();
QueryParser parser = new QueryParser("message", analyzer);
Query log = parser.parse("something OR name=mustafa");

Is there any posiblity to use this Query object with some sort of Map or POJO to test if that object matches the query? I know this is not intended usage of Lucene and it works on IndexSearcher but it would be useful to me.

Example what I have in mind:

Map<String,Object> a = {"message": "xx", "name": "mustafa"}
Map<String,Object> b = {"message": "xx", "name": "osman"}

SomeSearcher.matches(log, a) == true
SomeSearcher.matches(log, b) == false

Upvotes: 2

Views: 388

Answers (1)

Sabir Khan
Sabir Khan

Reputation: 10142

In my opinion, you can use org.apache.lucene.store.RAMDirectory

This way, your requirement to test out completely from memory is satisfied and also it would require very less changes to move to disk implementation after POC phase.

Upvotes: 1

Related Questions