java - How to determine In which indexed fields a token has matched? -
i search fields of objects "hibernate search".
my query:
final org.apache.lucene.search.query lucenequery = qb .keyword().wildcard() .onfields( fields ) .matching( valuetosearch ) .createquery(); // wrap lucene query in javax.persistence.query final javax.persistence.query jpaquery = fulltextentitymanager.createfulltextquery( lucenequery, vorgang.class ); // execute search final list<vorgang> resultlist = new arraylist<>(); ((list<vorgang>) jpaquery.getresultlist()).stream().filter( t -> projektids.contains( t.getprojektfk().getid() ) ) .foreach( vorgang -> resultlist.add( vorgang ) );
i want know in fields there match?
my idea was:
final list<vorgang> resultlist = new arraylist<>(); ( final string field : fields ) { final org.apache.lucene.search.query lucenequery = qb .keyword().wildcard() .onfield( field ) .matching( valuetosearch ) .createquery(); // wrap lucene query in javax.persistence.query final javax.persistence.query jpaquery = fulltextentitymanager.createfulltextquery( lucenequery, vorgang.class ); // execute search ((list<vorgang>) jpaquery.getresultlist()).stream().filter( t -> projektids.contains( t.getprojektfk().getid() ) ) .foreach( vorgang -> resultlist.add( vorgang ) ); }
but performance not good. want know fields, there match.
Comments
Post a Comment