Package org.hibernate.search.query.dsl

Examples of org.hibernate.search.query.dsl.QueryBuilder.keyword()


    Query query = monthQb.keyword().onField( "mythology" ).matching( "cold" ).createQuery();

    assertEquals( 0, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query based on several words
    query = monthQb.keyword().onField( "mythology" ).matching( "colder darker" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query applying the analyzer and generating one term per word
    query = monthQb.keyword().onField( "mythology_stem" ).matching( "snowboard" ).createQuery();
View Full Code Here


    query = monthQb.keyword().onField( "mythology" ).matching( "colder darker" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query applying the analyzer and generating one term per word
    query = monthQb.keyword().onField( "mythology_stem" ).matching( "snowboard" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query applying the analyzer and generating several terms per word
    query = monthQb.keyword().onField( "mythology_ngram" ).matching( "snobored" ).createQuery();
View Full Code Here

    query = monthQb.keyword().onField( "mythology_stem" ).matching( "snowboard" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query applying the analyzer and generating several terms per word
    query = monthQb.keyword().onField( "mythology_ngram" ).matching( "snobored" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query not using analyzers
    query = monthQb.keyword().onField( "mythology" ).ignoreAnalyzer().matching( "Month" ).createQuery();
View Full Code Here

    query = monthQb.keyword().onField( "mythology_ngram" ).matching( "snobored" ).createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //term query not using analyzers
    query = monthQb.keyword().onField( "mythology" ).ignoreAnalyzer().matching( "Month" ).createQuery();

    assertEquals( 0, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    transaction.commit();
  }
View Full Code Here

    final QueryBuilder monthQb = fullTextSession.getSearchFactory()
        .buildQueryBuilder().forEntity( Month.class ).get();


    //fuzzy search with custom threshold and prefix
    Query query = monthQb
        .keyword()
          .fuzzy()
            .withThreshold( .8f )
            .withPrefixLength( 1 )
          .onField( "mythology" )
View Full Code Here

          .createQuery();

    assertEquals( 1, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //fuzzy search on multiple fields
    query = monthQb
        .keyword()
        .fuzzy()
        .withThreshold( .8f )
        .withPrefixLength( 1 )
        .onFields( "mythology", "history" )
View Full Code Here

        .createQuery();

    assertEquals( 2, fullTextSession.createFullTextQuery( query, Month.class ).getResultSize() );

    //wildcard query
    query = monthQb
        .keyword()
          .wildcard()
          .onField( "mythology" )
          .matching( "mon*" )
          .createQuery();
View Full Code Here


    //combined query, January and february both contain whitening but February in a longer text
    Query query = monthQb
        .bool()
        .should( monthQb.keyword().onField( "mythology" ).matching( "whitening" ).createQuery() )
        .should( monthQb.keyword().onField( "history" ).matching( "whitening" ).createQuery() )
        .createQuery();

    List<Month> results = fullTextSession.createFullTextQuery( query, Month.class ).list();
    assertEquals( 2, results.size() );
View Full Code Here

    //combined query, January and february both contain whitening but February in a longer text
    Query query = monthQb
        .bool()
        .should( monthQb.keyword().onField( "mythology" ).matching( "whitening" ).createQuery() )
        .should( monthQb.keyword().onField( "history" ).matching( "whitening" ).createQuery() )
        .createQuery();

    List<Month> results = fullTextSession.createFullTextQuery( query, Month.class ).list();
    assertEquals( 2, results.size() );
    assertEquals( "January", results.get( 0 ).getName() );
View Full Code Here

    //boosted query, January and february both contain whitening but February in a longer text
    //since history is boosted, February should come first though
    query = monthQb
        .bool()
        .should( monthQb.keyword().onField( "mythology" ).matching( "whitening" ).createQuery() )
        .should( monthQb.keyword().onField( "history" ).boostedTo( 30 ).matching( "whitening" ).createQuery() )
        .createQuery();

    results = fullTextSession.createFullTextQuery( query, Month.class ).list();
    assertEquals( 2, results.size() );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.