-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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: 2536
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  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.