-->
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: keyword analyzer: MUST in stead of SHOULD
PostPosted: Tue Apr 16, 2013 10:46 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
When you pass a query text to a keyword query, the analyzer translates this text into terms using SHOULD. I'm running into a case now where I want this analysis to translate to MUST term queries. Is there a way to do this?


Top
 Profile  
 
 Post subject: Re: keyword analyzer: MUST in stead of SHOULD
PostPosted: Tue Apr 16, 2013 11:00 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
One of the ways I thought to get around this was to split up the query and loop over the terms and add them as a keyword query

Code:
      QueryBuilder qb = fts.getSearchFactory().buildQueryBuilder()
         .forEntity(Tag.class)
         .overridesForField("tag_kw_" + languageCode, "qryAutocompleteAnalyzer")
         .get();

      for(String key: qry.split(" ")){
         qb.keyword().onField("tag_kw_" + languageCode).ignoreFieldBridge().matching(key).createQuery();
      }


However, this leads to an exception being thrown when a stopword is being used (filtered out by the queryAnalyzer).

E.g. Surgery of the hand

Code:
org.hibernate.search.errors.EmptyQueryException: HSEARCH000146: The query string 'of' applied on field 'tag_kw_pt' has no meaningfull tokens to be matched. Validate the query input against the Analyzer applied on this field.
   at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:111)
   at org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder.createQuery(ConnectedMultiFieldsTermQueryBuilder.java:81)


This seems a bit strange. Both the query and runtime analyzer filter out stopwords so I would expect any resulting "empty query term" to just lead to it being ignored with a warning in stead of an exception being thrown.

In any case, is there a utility that I might use to get a on-the-fly list of terms against a text and analyzer I provide?


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.