Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Searching for a single letter
PostPosted: Sat Aug 27, 2016 1:54 am 
Newbie

Joined: Wed Mar 09, 2016 6:40 am
Posts: 4
In our current project we are maintaining status for each record , it is of length 1, lucene query is returning () when I search on single letter. Please assist me on solving this issue.

My query is:

luceneQuery = b.phrase().onField("trustLevel").sentence("a").createQuery();


Top
 Profile  
 
 Post subject: Re: Searching for a single letter
PostPosted: Fri Sep 09, 2016 5:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2505
Location: Third rock from the Sun
Hi,
if your records have a single letter you should try a keyword query. A phrase query is meant for complex sentences and paragraphs.

Code:
luceneQuery = new TermQuery( new Term( "trustLevel", "a" );


Also, make sure your trustLevel property is not being analyzed.

Quote:
@Field(analyze = Analyze.NO)


This will get you an "exact match" query, disabling all fuzziness. N.B. case will have to match as well.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.