[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HSEARCH-414) Add support for a Lucene query builder using a fluent API

Emmanuel Bernard (JIRA) noreply at atlassian.com
Fri Apr 16 12:20:58 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36476#action_36476 ] 

Emmanuel Bernard edited comment on HSEARCH-414 at 4/16/10 11:19 AM:
--------------------------------------------------------------------

I've made significant changes (as in break pretty much everything :) ). Let me know what you think

It looks cleaner now. You have several well defined layers:
 - chose the type of query (exact, fuzzy, wildcard)
 - (optional) customize query level operations (boost, constant score, filter)
 - select the targeted field
 - (optional) customize field level operations (boost, ignoreAnalyzer)
 - select the text to match
 - create the Lucene query

I plan to add multi field queries as well.

Questions:
 - does the query level vs field level distinction make sense?
 - fuzzy() or approximate() ?

Examples:

{code}
final QueryBuilder monthQb = fts.getSearchFactory()
				.buildQueryBuilder().forEntity( Month.class ).get();

Query 
//term query based on several words
query = monthQb.exact().onField( "mythology" ).matches( "colder darker" ).createQuery();

//fuzzy search with custom threshold and prefix
query = monthQb
		.fuzzy()
			.threshold( .8f )
			.prefixLength( 1 )
			.onField( "mythology" )
				.matches( "calder" )
				.createQuery();

//wildcard query
query = monthQb
		.wildcard()
			.onField( "mythology" )
				.matches( "mon*" )
				.createQuery();

//combined query, January and february both contain whitening but February in a longer text
query = monthQb
		.bool()
			.should( monthQb.exact().onField( "mythology" ).matches( "whitening" ).createQuery() )
			.should( monthQb.exact().onField( "history" ).matches( "whitening" ).createQuery() )
			.createQuery();
{code}

      was (Author: emmanuel):
    I've made significant changes (as in break pretty much everything :) ). Let me know what you think

It looks cleaner now. You have several well defined layers:
 - chose the type of query (exact, fuzzy, wildcard)
 - (optional) customize query level operations (boost, constant score, filter)
 - select the targeted field
 - (optional) customize field level operations (boost, ignoreAnalyzer)
 - select the text to match
 - create the Lucene query

I plan to add multi field queries as well.

Questions:
 - does the query level vs field level distinction make sense?
 - fuzzy() or approximate() ?

Examples:

{code}
final QueryBuilder monthQb = fts.getSearchFactory()
				.buildQueryBuilder().forEntity( Month.class ).get();

Query 
//term query based on several words
query = monthQb.exact().onField( "mythology" ).matches( "colder darker" ).createQuery();

//fuzzy search with custom threshold and prefix
query = monthQb
			.fuzzy()
				.threshold( .8f )
				.prefixLength( 1 )
				.onField( "mythology" )
					.matches( "calder" )
					.createQuery();

//wildcard query
query = monthQb
			.wildcard()
				.onField( "mythology" )
					.matches( "mon*" )
					.createQuery();

//combined query, January and february both contain whitening but February in a longer text
query = monthQb
			.bool()
				.should( monthQb.exact().onField( "mythology" ).matches( "whitening" ).createQuery() )
				.should( monthQb.exact().onField( "history" ).matches( "whitening" ).createQuery() )
				.createQuery();
{code}
  
> Add support for a Lucene query builder using a fluent API
> ---------------------------------------------------------
>
>                 Key: HSEARCH-414
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-414
>             Project: Hibernate Search
>          Issue Type: New Feature
>          Components: query
>            Reporter: Emmanuel Bernard
>             Fix For: 3.3.0
>
>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list