-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with wildcard query and the letter a
PostPosted: Wed Aug 17, 2011 6:56 am 
Newbie

Joined: Thu Jul 07, 2011 5:18 am
Posts: 10
Hi, I have a Problem with specific search terms.
If I search for the letter a,A, or a*,A*, i get this Exception :

exception [org.hibernate.search.SearchException: Try to search with an empty string

Does anyone know why this Problem happens ?
If I search for b,c,d and so on, I don't get any exception, only with a.

EDIT : Ah ok it seems that this Problem above only rises with this Analyzer :
@AnalyzerDef(name="customanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = NGramFilterFactory.class, params = {
@Parameter(name = "minGramSize", value = "3"),
@Parameter(name = "maxGramSize", value = "3")
}),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
@Parameter(name = "language", value = "German")})


With this not :
@AnalyzerDef(name="customanalyzer", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class))




And another Problem I have that there are no results when I search for "ab*" but there is Text in the index with "abc", "abd" and so on.
Do I have to use a Analyzer to make wildcard querys work ?

My setup for hibernate-search is here: https://forum.hibernate.org/viewtopic.php?f=9&t=1012245

EDIT_2 : Ok forgot the .wildcard() in the query, but why can't I search after .wildcard() for more than one field ?


Top
 Profile  
 
 Post subject: Re: Problem with wildcard query and the letter a
PostPosted: Wed Aug 17, 2011 1:32 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Toxor,
could you post the full stacktrace?

I guess the problem is that "a" is a stopword as defined by the German Snowball filter, still we definitely shouldn't allow it to throw an exception.

Be aware it's quite tricky to apply ngrams on top of snowball, maybe you should use both but keeping them each in it's own separate field (having multiple fields per property you need to index), then try to match both of them with a SHOULD boolean operator.

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


Top
 Profile  
 
 Post subject: Re: Problem with wildcard query and the letter a
PostPosted: Wed Aug 17, 2011 2:41 pm 
Newbie

Joined: Thu Jul 07, 2011 5:18 am
Posts: 10
s.grinovero wrote:
Hi Toxor,
could you post the full stacktrace?

I guess the problem is that "a" is a stopword as defined by the German Snowball filter, still we definitely shouldn't allow it to throw an exception.

Be aware it's quite tricky to apply ngrams on top of snowball, maybe you should use both but keeping them each in it's own separate field (having multiple fields per property you need to index), then try to match both of them with a SHOULD boolean operator.



Hi, thanks for your answer. I stopped using this Analyzer because of the Problem with a and a*. But I found out that this Analyzer works with a and a* when I'm using this query :
Code:
org.apache.lucene.search.Query query = qb.keyword().wildcard().onField("c.name").andField("c.fullName").andField("b.c.name").andField("e.name").matching(key).createQuery();


but not with this :
Code:
org.apache.lucene.search.Query query = qb.keyword().onFields("c.name","c.fullName","e.name","b.c.name").matching(key).createQuery();


So what I want to say is, that the query without the wildcard method, drops the error.

This is the Stacktrace :
Code:
Tests run: 5, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 3.202 sec <<< FAILURE!
find(ServiceTest)  Time elapsed: 0.017 sec  <<< ERROR!
org.hibernate.search.SearchException: Try to search with an empty string: c.name
   at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:103)
   at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:78)
   at DAOimpl.searchByKey(DAOimpl.java:82)
   at Service.searchByKey(ServiceImpl.java:1057)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy48.searchByKey(Unknown Source)
   at service.ServiceTest.find(ServiceTest.java:112)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
   at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
   at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
   at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
   at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
   at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
   at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.