Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-3498

Move optional predicate DSL parameters to the terminal contexts



      For example, the current syntax looks like this:

      .match().fuzzy().onField( "field1" ).orField( "field2" ).matching( value )
      .match().withConstantScore().onField( "field1" ).orField( "field2" ).matching( value )
      .match().boostedTo( 2.0f ).onField( "field1" ).boostedTo( 2.0f ).orField( "field2" ).matching( value ) // results in a boost of 4 for field1, 2 for field2, but one might think it will be 2 for each?
      .phrase().slop( 1 ).onField( "field1" ).orField( "field2" ).matching( phrase )
      .simpleQueryString().onField( "field1" ).orField( "field2" ).withAndAsDefaultOperator().matching( queryString )

      After this change, it would look like this:

      .match().onField( "field1" ).orField( "field2" ).matching( value ).fuzzy()
      .match().onField( "field1" ).orField( "field2" ).matching( value ).withConstantScore()
      .match().onField( "field1" ).boostedTo( 2.0f ).orField( "field2" ).matching( value ).boostedTo( 2.0f ) // It hardly makes sense to override the boost at the end, so maybe there's a lesser risk for the syntax to be misunderstood?
      .phrase().onField( "field1" ).orField( "field2" ).matching( phrase ).slop( 1 )
      .simpleQueryString().onField( "field1" ).orField( "field2" ).matching( queryString ).withAndAsDefaultOperator()


      1. More consistent: currently, some options are specified before the field path, some after. After this change, every option comes at the end. Note it's also more consistent with the projection/sort DSL, where options always come after we specify the field path.
      2. Easier to read: the main information is specified first (type of predicate, fields, value to match), and the details come later
      3. Clearer errors: some options (for example fuzzy) are supposed to throw an exception when applied to a field that doesn't support it (an integer field, for example). With the new syntax, we would be able to throw the exception when the option is set, because we know of all the targeted fields at that point. Currently we don't, so we throw the exception later, when matching is called, which is slightly confusing.


      1. Yet another syntax change. But we're hardly similar to Search 5 anymore, so one more syntax change is not the end of the world...


          Issue links



              • Assignee:
                yrodiere Yoann Rodière
                yrodiere Yoann Rodière
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: