问题描述:

I have a searchable domain class mapped to a table that has a flag column. Currently, when Lucene creates an index it generates a query like this (returns all data in the table):

 select this_.id as id0_0_,

this_.flag as flag2_0_0_,

this_.email as email0_0_, this_.first_name as first6_0_0_, this_.last_name as last8_0_0_

from ais_person this_

order by this_.id asc

Is it possible to build an index for only those rows which contain a specific flag value, so that the generated query would look like this:

 select this_.id as id0_0_,

this_.flag as flag2_0_0_,

this_.email as email0_0_, this_.first_name as first6_0_0_, this_.last_name as last8_0_0_

from ais_person this_

where this_.flag = 'Y'

order by this_.id asc

网友答案:

Yes, i think you can do that. Following is the pseudo-code.

   Document doc = new Document();
doc.add(Field.Text("flag", Y));
相关阅读:
Top