[hibernate-dev] [AND] Search: changing the way we search

Emmanuel Bernard emmanuel at hibernate.org
Thu Mar 20 10:08:32 EDT 2014


On Tue 2014-03-18 18:26, Guillaume Smet wrote:
> Hi,
> 
> On Tue, Mar 4, 2014 at 7:06 PM, Guillaume Smet <guillaume.smet at gmail.com> wrote:
> > I'll post as soon as I have a working prototype of what I would like
> > to achieve and then we can discuss from there.
> 
> I finally succeeded in committing a few hours to prototype what I have in mind:
> https://github.com/openwide-java/hibernate-search/commits/prototype-plain-text-search
> 
> It's a very simple patch. I added a test case to the DSLTest.
> 
> It's a work in progress but I think it might be easier to understand
> what I have in mind once you have taken a look at this.
> 
> I needed the SimpleQueryParser of Lucene 4.7 so I included it: it's a
> vanilla version so we can remove it after the move to 4.7.
> 
> What I would like to do:
> - add the ability to indicate that you want a fuzzy search for a given
> field in the DSL
> - I don't like the withAllTerms() option. I would like this behavior
> to be the default and to have something like "defaultOperatorIsOr()":
> it defines the default operator when you don't use an explicit one.
> I'm not sure defaultOperatorIsOr() is something
> acceptable/understandable.

I tend to disagree with you. The SimpleQueryBuilder seems to disagree
with you too as SHOULD is the default. Care to give your arguments in
favor of a different value for the default?

> 
> Where I would like advice/opinion:
> - does it look like a good idea or something horrible?

Yes that looks interesting to me. This machine is hard to describe to a
human though except with "it does the right thing... most of the time" :)

> - I'm still hesitant about what to do with field bridges: atm, I don't
> take them into account at all

The way I look at it, you won't likely be able to support fields that
are not texts in the first place.
So you could raise some exception if a selected field is not a
String field bridge. And we can expand from there.

You will get more info once field and class bridges expose more
metadata.

> - I think having a DSL branch for text search is necessary even if it
> might seem very similar to term search

I feel that you are right on that one but can you try and write down
your arguments?

Note that the QueryBuilder.createFieldQuery seems to do the right thing
when it comes to applying SHOULD between overlapping tokens and the
selected operator between "words" but I did not dive too much into the
logic.


More information about the hibernate-dev mailing list