Return Lucene field name when query matches

So I use MultiFieldQueryParser in Lucene 3.0.2, and I gave it some fields. I want to know which field matches the query; I searched here and one user said that it is absolutely impossible to do this. It's true? If so, can anyone recommend a way around a system that would allow me to do this?

I can put the whole document in one field, for example, “content”, but I think this makes the problem even worse.

I want to query a database, for example, using Brad, and see if the query was obtained from the name of the movie, the name of the actor, the name of the director, etc. etc.

thank

+3
source share
1 answer

BooleanQuery stnadard QueryParser:

BooleanQuery booleanQuery = new BooleanQuery();

FuzzyQuery field1Query = new FuzzyQuery(new Term("field1", searchTerm), 0.3f, 1, 10);
FuzzyQuery field2Query = new FuzzyQuery(new Term("field2", searchTerm), 0.3f, 1, 10);

booleanQuery.add(field1Query , BooleanClause.Occur.SHOULD);
booleanQuery.add(field1Query , BooleanClause.Occur.SHOULD);

, . , .

0

All Articles