Could someone help me with this code. I keep getting the following error - @In attribute requires non-null value: userSearchDao.fem
@Name( "userDao" ) @Scope( ScopeType.STATELESS ) @AutoCreate public class UserDAO { private final EntityManager em; @In FullTextEntityManager fem; public UserDAO() { em = ( EntityManager )Component.getInstance( "entityManager", true ); } @SuppressWarnings( "unchecked" ) public List<User> searchUsers( final String text ) { final Query query; try { FullTextEntityManager fem = Search.getFullTextEntityManager( em ); query = fem.createFullTextQuery( getLuceneQuery( text ), User.class ); return query.getResultList(); } catch ( ParseException ex ) { log.error( "search error", ex ); return null; } } private org.apache.lucene.search.Query getLuceneQuery( final String queryString ) throws ParseException { try { Map<String, Float> boostPerField = new HashMap<String, Float>( 2 ); boostPerField.put( "subject", (float) 4 ); boostPerField.put( "description", (float) 1 ); String[] searchFields = { "subject", "description" }; QueryParser parser = new MultiFieldQueryParser( Version.LUCENE_31, searchFields, new StandardAnalyzer( Version.LUCENE_31 ), boostPerField ); parser.setDefaultOperator( QueryParser.Operator.OR ); org.apache.lucene.search.Query luceneQuery = null; luceneQuery = parser.parse( queryString ); return luceneQuery; } catch ( ParseException ex ) { return null; } } }
Do not make multiple threads for the same question. It is very rude and will put people off answering you. The support given here is FREE so be patient and wait for someone to have the time to deal with it.
I replied here.