withSlop instead of slop looks like a good improvement (same for the fuzzy params etc)
I have not used phraseQuery() because what you get is not a query compared to createQuery(). That's why I think phrase is better than phraseQuery. But I'm open to other options. matching vs sentence etc There are definitely inconsistencies here :) "keyword on field A matching B" "range on field A from B to C" findKeyword, findInRange, findPhrase would be better? what about boolean queries? If e use this verb approach, "matching" is better than "match" "phrase on field A sentence" is wrong. I also want later in time to add the ability to set words with their position. phrase().onField("A").includingWord("C", 2); phrase().onField("A").includingWord("C", 2); What would be an alternative to "sentence" then? On 3 juin 2010, at 16:40, Sanne Grinovero wrote: > It's looking very good; I'll seek a couple of hours this weekend to > actually try it for real. > I don't think it need changes, but if you seek for in depth-criticism > I might add some additional fuel: > > I'm not 100% convinced about the use of "matching()" as method name, > it confuses me a bit. This might be because of my non-native english, > not sure. > Doesn't "match()" sound better? "searchMatch" ? > > Having: > monthQb > .phrase() > .slop( 1 ) > .onField( "mythology" ) > .sentence( "Month whitening" ) > > Here "sentence" takes the same logical role as "matching" ? > > WDYT about > > monthQb > .phraseQuery() // stress that's a kind of Query > .havingSlop( 1 ) || .withSlop( 1 ) > .onField( "mythology" ) > .searchSentence( "Month whitening" ) > ? > The method names are longer, but Imho there's a left part of the > sentence and a right part of the sentence; the left part migh have > options and be compound, the right part too. Waht is curretnyl missing > to make it better readable is to choose appropriate nouns to have a > clear separation to demark the end of the left part and the beginning > of the right part. > In the example above "slop" might look like a command, it sounds to me > like "do a slop with option 1", of course that doesn't make sense, but > is impairing readability. > > "searchSentence" > "searchMatch" > might be good delimiters for interpretation? > > Sanne > > 2010/6/3 Hardy Ferentschik <hibern...@ferentschik.de>: >> Looks fine to me looking at the examples. I haven't tried myself writing >> my own queries though >> to see the full potential. >> >> On Wed, 02 Jun 2010 18:00:20 +0200, Emmanuel Bernard >> <emman...@hibernate.org> wrote: >> >>> Guys, >>> I'me now done with the level of abstraction and fluidity I wanted out of >>> the query DSL. Please review before we push that out. Key features: >>> - fluent API >>> - use the field bridge system: type is passed, not raw string >>> - use the analyzer transparently >>> - simple use case simple, complex use cases possible >>> >>> I'm showing below a few examples demonstrating key concepts. >>> >>> Please comment / ask questions. >>> >>> Term query >>> query = monthQb >>> .keyword() >>> .onField( "monthValue" ) >>> .matching( 2 ) //note that monthValue is of type int >>> .createQuery(); >>> >>> //term query, showing analyzer integration >>> query = monthQb >>> .keyword() >>> .onField( "mythology_ngram" ) >>> .matching( "snobored" ) //we apply the ngram filter here >>> .createQuery(); >>> >>> //use fuzzy query >>> query = monthQb >>> .keyword() >>> .fuzzy() >>> .threshold( .8f ) //optional >>> .prefixLength( 1 ) //optional >>> .onField( "mythology" ) >>> .matching( "calder" ) >>> .createQuery(); >>> >>> //use wildcard queries >>> monthQb >>> .keyword() >>> .wildcard() >>> .onField( "mythology" ) >>> .matching( "mon*" ) >>> .createQuery(); >>> >>> Alternative option >>> //apply on multiple fields >>> monthQb.keyword() >>> .onField( "mythology" ) >>> .boostedTo( 30 ) >>> .andField( "history" ) >>> .matching( "whitening" ) >>> .createQuery(); >>> >>> //boost a field >>> monthQb >>> .keyword() >>> .onField( "history" ) >>> .boostedTo( 30 ) >>> .matching( "whitening" ) >>> .createQuery(); >>> >>> Range query >>> //Range query >>> monthQb >>> .range() >>> .onField( "estimatedCreation" ) >>> .from( from ) #from and to are actual java.util.Date. We do >>> the >>> conversion >>> .to( to ).exclude() >>> .createQuery(); >>> >>> monthQb >>> .range() >>> .onField( "estimatedCreation" ) >>> .below( brithDay ) >>> .createQuery(); >>> >>> Phrase query >>> monthQb >>> .phrase() >>> .slop( 1 ) >>> .onField( "mythology" ) >>> .sentence( "Month whitening" ) >>> .createQuery(); >>> >>> Boolean query >>> monthQb >>> .bool() >>> .should( monthQb.keyword().onField( "mythology" ).matching( >>> "whitening" ).createQuery() ) >>> .should( monthQb.keyword().onField( "history" ).matching( >>> "whitening" >>> ).createQuery() ) >>> .createQuery(); >>> >>> //Boolean query all except (recommended) >>> monthQb >>> .all() >>> .except( monthQb.keyword().onField( "mythology" ).matching( >>> "colder" >>> ).createQuery() ) >>> .createQuery(); >>> >>> _______________________________________________ >>> hibernate-dev mailing list >>> hibernate-dev@lists.jboss.org >>> https://lists.jboss.org/mailman/listinfo/hibernate-dev >> >> _______________________________________________ >> hibernate-dev mailing list >> hibernate-dev@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/hibernate-dev >> _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev