Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Apache Lucene question

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
qb.keyword().onFields(searchFieldNamesArray).matching(searchTerm).createQuery()

qb is hibernate querybuilder, and the above statement return org.apache.lucene.search.Query .

the problem is 'stopword' in lucene, how can i disable it. since my searchterm could be value like 'a' 'an', etc.

solution:

org.apache.lucene.search.Query queryState = bool.createQuery();

MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_30,searchFieldNamesArray, new org.apache.lucene.analysis.standard.StandardAnalyzer(Version.LUCENE_30, new HashSet()));
org.apache.lucene.search.Query queryFields = null;
try{
queryFields = parser.parse(searchTerm);
}catch(ParseException e){

}

giving new HashSet(), will disable stopword.
 
Aaaaaand ... we're on the march. Stylin. Get with it tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!