-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Search and normalized query
PostPosted: Wed Aug 08, 2012 8:33 am 
Newbie

Joined: Mon Feb 20, 2012 10:36 am
Posts: 3
I am looking for a way how to get normalized query if there is StopFilter in
a search query processing. Now If a user sends a search string for instance with "a" letter only, query result is
"org.hibernate.search.SearchException: Try to search with an empty string: title:ngrams"

What I need to achieve is to have a validation of a search string on UI before search query is sent.

Is that available in HSearch 4.1?

If you could point me to existing example or documentation I would appreciate it.


Top
 Profile  
 
 Post subject: Re: Hibernate Search and normalized query
PostPosted: Thu Aug 09, 2012 4:09 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
what do you mean by "UI validation" ? It is not possible to do it on the client side, at least not without writing your own custom validator. This should be done by catching the exception, as it's not possible to pre-validate this via a regular expression (or similar rules) as it depends on the plugged analyzer implementation.

It's a great idea to improve on with a Bean Validation extension, but that doesn't currently exist.

Depending on your use case, you might want to swallow the exception and return an empty list as search results.

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


Top
 Profile  
 
 Post subject: Re: Hibernate Search and normalized query
PostPosted: Thu Aug 09, 2012 4:25 am 
Newbie

Joined: Mon Feb 20, 2012 10:36 am
Posts: 3
sanne.grinovero wrote:
Hi,
what do you mean by "UI validation" ? It is not possible to do it on the client side, at least not without writing your own custom validator. This should be done by catching the exception, as it's not possible to pre-validate this via a regular expression (or similar rules) as it depends on the plugged analyzer implementation.


So getting a list of stop words from plugged analyzer implementation by calling an HSearch API is not available at all, right? I would do my own prevalidation check, but need to get stop words list from plugged analyzer impl.

hmm, org.hibernate.search.SearchException is general search exception and that swallowing could be tricky for users of an app.


Top
 Profile  
 
 Post subject: Re: Hibernate Search and normalized query
PostPosted: Thu Aug 09, 2012 4:38 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
So getting a list of stop words from plugged analyzer implementation by calling an HSearch API is not available at all, right? I would do my own prevalidation check, but need to get stop words list from plugged analyzer impl.

Right that's not available. Keep in mind that not all analyzers have stopwords, and a smart one might have a context-dependent analyzer, for example the "a" token might be considered a stopword depending on its relative position to other tokens; most common implementations aren't that smart but it's an option we should be able to deal with.

Rather than asking the list of stopwords to the framework, I'd add a method to let the framework say if a specific query string has any chance to return some results.. but this is very close in terms of functionality to actually executing the query.

Quote:
hmm, org.hibernate.search.SearchException is general search exception and that swallowing could be tricky for users of an app.

Totally agree, in fact we have a thread on the mailing list in which I proposed to subclass the exception to a specific type for this case. But this is not available in 4.1, so you're right this might be a bad idea until we change that.

_________________
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.  [ 4 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.