Package org.hibernate.search.query.dsl

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


    em.clear();

    em.getTransaction().begin();
    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    Query query = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    FullTextQuery hibernateQuery = em.createFullTextQuery( query, Clock.class );

    hibernateQuery.setHint( "javax.persistence.query.timeout", 100 ); //not too low or we can't reproduce it consistently
    try {
      hibernateQuery.getResultSize();
View Full Code Here


    em.clear();

    em.getTransaction().begin();
    final QueryBuilder builder = em.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    Query query = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    FullTextQuery hibernateQuery = em.createFullTextQuery( query, Clock.class );
    List results = hibernateQuery.getResultList();
    assertEquals( 500, results.size() );

    em.clear();
View Full Code Here

    List results = hibernateQuery.getResultList();
    assertEquals( 500, results.size() );

    em.clear();

    query = builder.keyword().onField( "brand" ).matching( "Swatch" ).createQuery();
    hibernateQuery = em.createFullTextQuery( query, Clock.class );
    hibernateQuery.limitExecutionTimeTo( 1, TimeUnit.NANOSECONDS );
    List result = hibernateQuery.getResultList();
    System.out.println( "Result size early: " + result.size() );
    assertEquals( "Test early failure, before the number of results are even fetched", 0, result.size() );
View Full Code Here

  @Before
  public void setUp() throws Exception {
    super.setUp();
    fts = Search.getFullTextSession( openSession() );
    QueryBuilder builder = fts.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    allSeikoClocksQuery = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    allSwatchClocksQuery = builder.keyword().onField( "brand" ).matching( "Swatch" ).createQuery();
    noMatchQuery = builder.keyword().onField( "brand" ).matching( "Blah" ).createQuery();
    matchAllQuery = builder.all().createQuery();
    storeClocks( fts );
  }
View Full Code Here

  public void setUp() throws Exception {
    super.setUp();
    fts = Search.getFullTextSession( openSession() );
    QueryBuilder builder = fts.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    allSeikoClocksQuery = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    allSwatchClocksQuery = builder.keyword().onField( "brand" ).matching( "Swatch" ).createQuery();
    noMatchQuery = builder.keyword().onField( "brand" ).matching( "Blah" ).createQuery();
    matchAllQuery = builder.all().createQuery();
    storeClocks( fts );
  }
View Full Code Here

    super.setUp();
    fts = Search.getFullTextSession( openSession() );
    QueryBuilder builder = fts.getSearchFactory().buildQueryBuilder().forEntity( Clock.class ).get();
    allSeikoClocksQuery = builder.keyword().onField( "brand" ).matching( "Seiko" ).createQuery();
    allSwatchClocksQuery = builder.keyword().onField( "brand" ).matching( "Swatch" ).createQuery();
    noMatchQuery = builder.keyword().onField( "brand" ).matching( "Blah" ).createQuery();
    matchAllQuery = builder.all().createQuery();
    storeClocks( fts );
  }

  @Override
View Full Code Here

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

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

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

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

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

    assertEquals( 2, results.size() );
    assertEquals( "January", results.get( 0 ).getName() );

    //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.keyword()
        .onField( "mythology" )
        .andField( "history" )
          .boostedTo( 30 )
        .matching( "whitening" )
        .createQuery();
View Full Code Here

          .buildQueryBuilder()
          .forEntity( Car.class )
          .get();

      // build a Lucene query
      final Query query = builder.keyword().onField( "make" ).matching( queryString ).createQuery();

      // create facets for navigation
      // discrete faceting
      final FacetingRequest colorFacet = builder.facet()
          .name( colorFacetName )
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.