org.hibernate.search.query.dsl.QueryBuilder.keyword() - java examples

Here are the examples of the java api org.hibernate.search.query.dsl.QueryBuilder.keyword() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

65 Examples 7

18 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public Query matchNull(QueryBuilder builder, String fieldPath) {
    return builder.keyword().onField(fieldPath).matching(null).createQuery();
}

18 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public Query matchOneTermIfGiven(QueryBuilder builder, String fieldPath, String terms) {
    if (!StringUtils.hasText(terms)) {
        return null;
    }
    return builder.keyword().onField(fieldPath).matching(terms).createQuery();
}

18 View Complete Implementation : QueryBuilderDelegate.java
Copyright Apache License 2.0
Author : thorntail
@Override
public TermContext keyword() {
    return delegate.keyword();
}

18 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public Query matchIfTrue(QueryBuilder builder, String fieldPath, boolean value, Boolean mustMatch) {
    if (mustMatch == null || !mustMatch) {
        return null;
    }
    return builder.keyword().onField(fieldPath).matching(value).createQuery();
}

18 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public <P> Query beIncludedIfGiven(QueryBuilder builder, String fieldPath, P value) {
    if (value == null) {
        return null;
    }
    return builder.keyword().onField(fieldPath).matching(value).createQuery();
}

18 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public <P> Query matchIfGiven(QueryBuilder builder, String fieldPath, P value) {
    if (value == null) {
        return null;
    }
    return builder.keyword().onField(fieldPath).matching(value).createQuery();
}

17 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public <P> Query matchOneIfGiven(QueryBuilder builder, String fieldPath, Collection<? extends P> possibleValues) {
    if (possibleValues == null || possibleValues.isEmpty()) {
        return null;
    }
    BooleanJunction<?> subJunction = builder.bool();
    for (P possibleValue : possibleValues) {
        subJunction.should(builder.keyword().onField(fieldPath).matching(possibleValue).createQuery());
    }
    return subJunction.createQuery();
}

17 View Complete Implementation : HibernateSearchLuceneQueryFactoryImpl.java
Copyright Apache License 2.0
Author : igloo-project
@Override
public <P> Query matchAllIfGiven(QueryBuilder builder, String fieldPath, Collection<? extends P> values) {
    if (values == null || values.isEmpty()) {
        return null;
    }
    BooleanJunction<?> subJunction = builder.bool();
    for (P possibleValue : values) {
        subJunction.must(builder.keyword().onField(fieldPath).matching(possibleValue).createQuery());
    }
    return subJunction.createQuery();
}

17 View Complete Implementation : JpaDb.java
Copyright GNU Affero General Public License v3.0
Author : ZapBlasterson
/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.crushpaper.DbInterface#searchEntriesForUserHelper(java.lang.String,
	 * java.lang.String, java.lang.String, int, int)
	 */
@Override
public List<?> searchEntriesForUserHelper(String userId, String field, String query, int startPosition, int maxResults) {
    if (userId == null || userId.isEmpty() || !idGenerator.isIdWellFormed(userId)) {
        return new ArrayList<Entry>();
    }
    if (query == null) {
        return new ArrayList<Entry>();
    }
    if (field == null) {
        return new ArrayList<Entry>();
    }
    FullTextEnreplacedyManager fullTextEnreplacedyManager = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(getOrCreateEnreplacedyManager());
    QueryBuilder qb = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Entry.clreplaced).get();
    org.apache.lucene.search.Query luceneQuery = qb.bool().must(qb.keyword().onField(field).matching(query).createQuery()).must(new TermQuery(new Term("userId", userId))).createQuery();
    javax.persistence.Query jpaQuery = fullTextEnreplacedyManager.createFullTextQuery(luceneQuery, Entry.clreplaced).setFirstResult(startPosition).setMaxResults(maxResults);
    return jpaQuery.getResultList();
}

17 View Complete Implementation : LuceneQueryMaker.java
Copyright Apache License 2.0
Author : infinispan
@Override
public Query visit(LikeExpr likeExpr) {
    PropertyValueExpr propertyValueExpr = (PropertyValueExpr) likeExpr.getChild();
    StringBuilder lucenePattern = new StringBuilder(likeExpr.getPattern(namedParameters));
    // transform 'Like' pattern into Lucene wildcard pattern
    boolean isEscaped = false;
    for (int i = 0; i < lucenePattern.length(); i++) {
        char c = lucenePattern.charAt(i);
        if (!isEscaped && c == likeExpr.getEscapeChar()) {
            isEscaped = true;
            lucenePattern.deleteCharAt(i);
        } else {
            if (isEscaped) {
                isEscaped = false;
            } else {
                if (c == LikeExpr.MULTIPLE_CHARACTERS_WILDCARD) {
                    lucenePattern.setCharAt(i, LUCENE_MULTIPLE_CHARACTERS_WILDCARD);
                    continue;
                } else if (c == LikeExpr.SINGLE_CHARACTER_WILDCARD) {
                    lucenePattern.setCharAt(i, LUCENE_SINGLE_CHARACTER_WILDCARD);
                    continue;
                }
            }
            if (c == LUCENE_SINGLE_CHARACTER_WILDCARD || c == LUCENE_MULTIPLE_CHARACTERS_WILDCARD) {
                lucenePattern.insert(i, LUCENE_WILDCARD_ESCAPE_CHARACTER);
                i++;
            }
        }
    }
    return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().wildcard().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(lucenePattern.toString()).createQuery();
}

17 View Complete Implementation : AssociationMassIndexerTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
private void replacedertEnreplacedyHasBeenIndexed() throws Exception {
    FullTextEnreplacedyManager fullTextEm = Search.getFullTextEnreplacedyManager(createEnreplacedyManager());
    fullTextEm.getTransaction().begin();
    QueryBuilder queryBuilder = fullTextEm.getSearchFactory().buildQueryBuilder().forEnreplacedy(IndexedNews.clreplaced).get();
    Query luceneQuery = queryBuilder.keyword().wildcard().onField("newsId").ignoreFieldBridge().matching("replaced*").createQuery();
    @SuppressWarnings("unchecked")
    List<IndexedNews> list = fullTextEm.createFullTextQuery(luceneQuery).getResultList();
    replacedertThat(list).hreplacedize(1);
    List<IndexedLabel> labels = list.get(0).getLabels();
    replacedertThat(labels).hreplacedize(2);
    replacedertThat(contains(labels, "mreplacedindex")).isTrue();
    replacedertThat(contains(labels, "test")).isTrue();
    fullTextEm.getTransaction().commit();
    fullTextEm.close();
}

16 View Complete Implementation : HibernateSearchWithElasticsearchIT.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void queryOnMultipleFields() {
    EnreplacedyManager em = emf.createEnreplacedyManager();
    inTransaction(em, tx -> {
        FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
        QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(VideoGame.clreplaced).get();
        FullTextQuery query = ftem.createFullTextQuery(qb.keyword().onFields("replacedle", "description").matching("samurai").createQuery(), VideoGame.clreplaced);
        List<VideoGame> videoGames = query.getResultList();
        replacedertThat(videoGames).onProperty("replacedle").containsExactly("Revenge of the Samurai", "Tanaka's return");
    });
    em.close();
}

16 View Complete Implementation : AssociationMassIndexerTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
@SuppressWarnings("unchecked")
private void replacedertreplacedociatedElementsHaveBeenIndexed() throws Exception {
    FullTextEnreplacedyManager fullTextEm = Search.getFullTextEnreplacedyManager(createEnreplacedyManager());
    fullTextEm.getTransaction().begin();
    QueryBuilder b = fullTextEm.getSearchFactory().buildQueryBuilder().forEnreplacedy(IndexedLabel.clreplaced).get();
    {
        Query luceneQuery = b.keyword().wildcard().onField("name").matching("tes*").createQuery();
        List<IndexedLabel> labels = fullTextEm.createFullTextQuery(luceneQuery).getResultList();
        replacedertThat(labels).hreplacedize(1);
        replacedertThat(contains(labels, "test")).isTrue();
    }
    {
        Query luceneQuery = b.keyword().wildcard().onField("name").matching("mas*").createQuery();
        List<IndexedLabel> labels = fullTextEm.createFullTextQuery(luceneQuery).getResultList();
        replacedertThat(labels).hreplacedize(1);
        replacedertThat(contains(labels, "mreplacedindex")).isTrue();
    }
    fullTextEm.getTransaction().commit();
    fullTextEm.close();
}

16 View Complete Implementation : LuceneQueryMaker.java
Copyright Apache License 2.0
Author : infinispan
@Override
public Query visit(IsNullExpr isNullExpr) {
    PropertyValueExpr propertyValueExpr = (PropertyValueExpr) isNullExpr.getChild();
    return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(null).createQuery();
}

16 View Complete Implementation : ProjectionTest.java
Copyright Apache License 2.0
Author : infinispan
private CacheQuery<?> createProjectionQuery(String... projection) {
    QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClreplaced(Foo.clreplaced).get();
    Query query = queryBuilder.keyword().onField("bar").matching("bar1").createQuery();
    return searchManager.getQuery(query).projection(projection);
}

16 View Complete Implementation : FulltextSearchSvcImpl.java
Copyright Apache License 2.0
Author : jamesagnew
private void addTextSearch(QueryBuilder theQueryBuilder, BooleanJunction<?> theBoolean, List<List<IQueryParameterType>> theTerms, String theFieldName, String theFieldNameEdgeNGram, String theFieldNameNGram) {
    if (theTerms == null) {
        return;
    }
    for (List<? extends IQueryParameterType> nextAnd : theTerms) {
        Set<String> terms = new HashSet<>();
        for (IQueryParameterType nextOr : nextAnd) {
            StringParam nextOrString = (StringParam) nextOr;
            String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
            if (isNotBlank(nextValueTrimmed)) {
                terms.add(nextValueTrimmed);
            }
        }
        if (terms.isEmpty() == false) {
            if (terms.size() == 1) {
                // @formatter:off
                Query textQuery = theQueryBuilder.phrase().withSlop(2).onField(theFieldName).boostedTo(4.0f).sentence(terms.iterator().next().toLowerCase()).createQuery();
                // @formatter:on
                theBoolean.must(textQuery);
            } else {
                String joinedTerms = StringUtils.join(terms, ' ');
                theBoolean.must(theQueryBuilder.keyword().onField(theFieldName).matching(joinedTerms).createQuery());
            }
        }
    }
}

16 View Complete Implementation : UserSearch.java
Copyright MIT License
Author : netgloo
// ------------------------
// PUBLIC METHODS
// ------------------------
/**
 * A basic search for the enreplacedy User. The search is done by exact match per
 * keywords on fields name, city and email.
 *
 * @param text The query text.
 */
public List<User> search(String text) {
    // get the full text enreplacedy manager
    FullTextEnreplacedyManager fullTextEnreplacedyManager = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(enreplacedyManager);
    // create the query using Hibernate Search query DSL
    QueryBuilder queryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(User.clreplaced).get();
    // a very basic query by keywords
    org.apache.lucene.search.Query query = queryBuilder.keyword().onFields("name", "city", "email").matching(text).createQuery();
    // wrap Lucene query in an Hibernate Query object
    org.hibernate.search.jpa.FullTextQuery jpaQuery = fullTextEnreplacedyManager.createFullTextQuery(query, User.clreplaced);
    // execute search and return results (sorted by relevance as default)
    @SuppressWarnings("unchecked")
    List<User> results = jpaQuery.getResultList();
    return results;
}

16 View Complete Implementation : UserDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
private FullTextQuery getSearchQuery(String searchTerm) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(getEnreplacedyManager());
    QueryBuilder userQueryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(User.clreplaced).get();
    BooleanJunction<?> booleanJunction = userQueryBuilder.bool();
    if (StringUtils.hasText(searchTerm)) {
        booleanJunction.must(userQueryBuilder.keyword().fuzzy().withPrefixLength(1).withThreshold(0.8F).onField(Binding.user().userName().getPath()).andField(Binding.user().fullName().getPath()).matching(searchTerm).createQuery());
    } else {
        booleanJunction.must(userQueryBuilder.all().createQuery());
    }
    return fullTextEnreplacedyManager.createFullTextQuery(booleanJunction.createQuery(), User.clreplaced);
}

16 View Complete Implementation : HibernateSearchWithElasticsearchIT.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void queryOnSingleField() {
    EnreplacedyManager em = emf.createEnreplacedyManager();
    inTransaction(em, tx -> {
        FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
        QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(VideoGame.clreplaced).get();
        FullTextQuery query = ftem.createFullTextQuery(qb.keyword().onField("replacedle").matching("samurai").createQuery(), VideoGame.clreplaced);
        List<VideoGame> videoGames = query.getResultList();
        replacedertThat(videoGames).onProperty("replacedle").containsExactly("Revenge of the Samurai");
    });
    em.close();
}

16 View Complete Implementation : HibernateSearchWithElasticsearchIT.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void projection() {
    EnreplacedyManager em = emf.createEnreplacedyManager();
    inTransaction(em, tx -> {
        FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
        QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(VideoGame.clreplaced).get();
        FullTextQuery query = ftem.createFullTextQuery(qb.keyword().onField("tags").matching("round-based").createQuery(), VideoGame.clreplaced).setProjection("replacedle", "publisher.name", "release");
        Object[] projection = (Object[]) query.getSingleResult();
        replacedertThat(projection[0]).isEqualTo("Tanaka's return");
        replacedertThat(projection[1]).isEqualTo("Samurai Games, Inc.");
        replacedertThat(projection[2]).isEqualTo(new GregorianCalendar(2011, 2, 13).getTime());
        query = ftem.createFullTextQuery(qb.keyword().onField("tags").matching("round-based").createQuery(), VideoGame.clreplaced).setProjection(ElasticsearchProjectionConstants.SCORE, ElasticsearchProjectionConstants.SOURCE);
        projection = (Object[]) query.getSingleResult();
        System.out.println(Arrays.toString(projection));
    });
    em.close();
}

16 View Complete Implementation : HibernateSearchWithElasticsearchIT.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void projectionWithTransformer() {
    EnreplacedyManager em = emf.createEnreplacedyManager();
    inTransaction(em, tx -> {
        FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
        QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(VideoGame.clreplaced).get();
        FullTextQuery query = ftem.createFullTextQuery(qb.keyword().onField("tags").matching("round-based").createQuery(), VideoGame.clreplaced).setProjection("replacedle", "publisher.name", "release").setResultTransformer(new BasicTransformerAdapter() {

            @Override
            public VideoGameDto transformTuple(Object[] tuple, String[] aliases) {
                return new VideoGameDto((String) tuple[0], (String) tuple[1], (Date) tuple[2]);
            }
        });
        VideoGameDto projection = (VideoGameDto) query.getSingleResult();
        replacedertThat(projection.getreplacedle()).isEqualTo("Tanaka's return");
        replacedertThat(projection.getPublisherName()).isEqualTo("Samurai Games, Inc.");
        replacedertThat(projection.getRelease()).isEqualTo(new GregorianCalendar(2011, 2, 13).getTime());
    });
    em.close();
}

16 View Complete Implementation : HibernateSearchWithElasticsearchIT.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void wildcardQuery() {
    EnreplacedyManager em = emf.createEnreplacedyManager();
    inTransaction(em, tx -> {
        FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
        QueryBuilder qb = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(VideoGame.clreplaced).get();
        FullTextQuery query = ftem.createFullTextQuery(qb.keyword().wildcard().onFields("replacedle", "description").matching("sam*").createQuery(), VideoGame.clreplaced);
        List<VideoGame> videoGames = query.getResultList();
        replacedertThat(videoGames).onProperty("replacedle").containsExactly("Revenge of the Samurai", "Tanaka's return");
    });
    em.close();
}

15 View Complete Implementation : HibernateSearch5InstrumentationTest.java
Copyright Apache License 2.0
Author : elastic
@Test
void performMultiResultLuceneIndexSearch() {
    FullTextEnreplacedyManager fullTextSession = Search.getFullTextEnreplacedyManager(enreplacedyManager);
    QueryBuilder builder = fullTextSession.getSearchFactory().buildQueryBuilder().forEnreplacedy(Dog.clreplaced).get();
    BooleanJunction<BooleanJunction> bool = builder.bool();
    bool.should(builder.keyword().wildcard().onField("name").matching("dog*").createQuery());
    Query query = bool.createQuery();
    FullTextQuery ftq = fullTextSession.createFullTextQuery(query, Dog.clreplaced);
    List<Dog> result = (List<Dog>) ftq.getResultList();
    replacedertAll(() -> {
        replacedertThat(result.size()).isEqualTo(2);
        replacedertApmSpanInformation(reporter, "name:dog*", "list");
    });
}

15 View Complete Implementation : HibernateSearchAtopOgmTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
@Test
public void testHibernateSearchJPAAPIUsage() throws Exception {
    final FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(getFactory().createEnreplacedyManager());
    ftem.getTransaction().begin();
    final Insurance insurance = new Insurance();
    insurance.setName("Macif");
    ftem.persist(insurance);
    ftem.getTransaction().commit();
    ftem.clear();
    ftem.getTransaction().begin();
    final QueryBuilder b = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(Insurance.clreplaced).get();
    final Query lq = b.keyword().onField("name").matching("Macif").createQuery();
    final FullTextQuery ftQuery = ftem.createFullTextQuery(lq, Insurance.clreplaced);
    final List<Insurance> resultList = ftQuery.getResultList();
    replacedertThat(getFactory().getPersistenceUnitUtil().isLoaded(resultList.get(0))).isTrue();
    replacedertThat(resultList).hreplacedize(1);
    for (Object e : resultList) {
        ftem.remove(e);
    }
    ftem.getTransaction().commit();
    ftem.close();
}

15 View Complete Implementation : MagicCardsCollectionBean.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
public List<MagicCard> findByName(String name) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(em);
    QueryBuilder queryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(MagicCard.clreplaced).get();
    Query query = queryBuilder.keyword().onField("name").matching(name).createQuery();
    return fullTextEnreplacedyManager.createFullTextQuery(query, MagicCard.clreplaced).getResultList();
}

15 View Complete Implementation : RegistrationExecutor.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
public static Member findWithEmail(EnreplacedyManager em, String email) {
    FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(em);
    QueryBuilder b = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(Member.clreplaced).get();
    Query lq = b.keyword().wildcard().onField("email").matching(email).createQuery();
    Object uniqueResult = ftem.createFullTextQuery(lq).getSingleResult();
    return (Member) uniqueResult;
}

15 View Complete Implementation : TweetRepositoryImpl.java
Copyright Apache License 2.0
Author : michael-simons
@Override
@Transactional(readOnly = true)
public List<TweetEnreplacedy> searchByKeyword(final String keywords, final LocalDate from, final LocalDate to) {
    // Must be retrieved inside a transaction to take part of
    final FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(enreplacedyManager);
    // Prepare a search query builder
    final QueryBuilder queryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(TweetEnreplacedy.clreplaced).get();
    // This is a boolean junction... I'll add at least a keyword query
    final BooleanJunction<BooleanJunction> outer = queryBuilder.bool();
    outer.must(queryBuilder.keyword().onFields("content").matching(keywords).createQuery());
    // And then 2 range queries if from and to are not null
    Optional.ofNullable(from).map(// Must be a zoned date time to fit the field
    f -> f.atStartOfDay(UTC)).map(f -> queryBuilder.range().onField("created_at").above(f).createQuery()).ifPresent(q -> outer.must(q));
    Optional.ofNullable(to).map(// Same here, but a day later
    f -> f.plusDays(1).atStartOfDay(UTC)).map(// which i exclude
    f -> queryBuilder.range().onField("created_at").below(f).excludeLimit().createQuery()).ifPresent(q -> outer.must(q));
    return fullTextEnreplacedyManager.createFullTextQuery(outer.createQuery(), TweetEnreplacedy.clreplaced).getResultList();
}

14 View Complete Implementation : OwnerDaoImpl.java
Copyright GNU General Public License v2.0
Author : thomaswoehlke
@Override
public List<Owner> search(String searchterm) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(enreplacedyManager);
    QueryBuilder qb = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Owner.clreplaced).get();
    org.apache.lucene.search.Query query = qb.keyword().onFields("firstName", "lastName", "city", "pets.name").matching(searchterm).createQuery();
    // wrap Lucene query in a javax.persistence.Query
    javax.persistence.Query persistenceQuery = fullTextEnreplacedyManager.createFullTextQuery(query, Owner.clreplaced);
    // execute search
    @SuppressWarnings("unchecked")
    List<Owner> result = persistenceQuery.getResultList();
    return result;
}

14 View Complete Implementation : VetDaoImpl.java
Copyright GNU General Public License v2.0
Author : thomaswoehlke
@Override
public List<Vet> search(String searchterm) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(enreplacedyManager);
    QueryBuilder qb = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Vet.clreplaced).get();
    org.apache.lucene.search.Query query = qb.keyword().onFields("firstName", "lastName").matching(searchterm).createQuery();
    // wrap Lucene query in a javax.persistence.Query
    javax.persistence.Query persistenceQuery = fullTextEnreplacedyManager.createFullTextQuery(query, Vet.clreplaced);
    // execute search
    @SuppressWarnings("unchecked")
    List<Vet> result = persistenceQuery.getResultList();
    return result;
}

13 View Complete Implementation : FulltextSearchSvcImpl.java
Copyright Apache License 2.0
Author : jamesagnew
private List<ResourcePersistentId> doSearch(String theResourceName, SearchParameterMap theParams, ResourcePersistentId theReferencingPid) {
    FullTextEnreplacedyManager em = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(myEnreplacedyManager);
    List<ResourcePersistentId> pids = null;
    /*
		 * Handle textual params
		 */
    /*
		for (String nextParamName : theParams.keySet()) {
			for (List<? extends IQueryParameterType> nextAndList : theParams.get(nextParamName)) {
				for (Iterator<? extends IQueryParameterType> orIterator = nextAndList.iterator(); orIterator.hasNext();) {
					IQueryParameterType nextParam = orIterator.next();
					if (nextParam instanceof TokenParam) {
						TokenParam nextTokenParam = (TokenParam) nextParam;
						if (nextTokenParam.isText()) {
							orIterator.remove();
							QueryBuilder qb = em.getSearchFactory().buildQueryBuilder().forEnreplacedy(ResourceIndexedSearchParamString.clreplaced).get();
							BooleanJunction<?> bool = qb.bool();

							bool.must(qb.keyword().onField("myParamName").matching(nextParamName).createQuery());
							if (isNotBlank(theResourceName)) {
								bool.must(qb.keyword().onField("myResourceType").matching(theResourceName).createQuery());
							}
//							
							//@formatter:off
							String value = nextTokenParam.getValue().toLowerCase();
							bool.must(qb.keyword().onField("myValueTextEdgeNGram").matching(value).createQuery());
							
							//@formatter:on
							
							FullTextQuery ftq = em.createFullTextQuery(bool.createQuery(), ResourceIndexedSearchParamString.clreplaced);

							List<?> resultList = ftq.getResultList();
							pids = new ArrayList<Long>();
							for (Object next : resultList) {
								ResourceIndexedSearchParamString nextAsArray = (ResourceIndexedSearchParamString) next;
								pids.add(nextAsArray.getResourcePid());
							}
						}
					}
				}
			}
		}
		
		if (pids != null && pids.isEmpty()) {
			return pids;
		}
		*/
    QueryBuilder qb = em.getSearchFactory().buildQueryBuilder().forEnreplacedy(ResourceTable.clreplaced).get();
    BooleanJunction<?> bool = qb.bool();
    /*
		 * Handle _content parameter (resource body content)
		 */
    List<List<IQueryParameterType>> contentAndTerms = theParams.remove(Constants.PARAM_CONTENT);
    addTextSearch(qb, bool, contentAndTerms, "myContentText", "myContentTextEdgeNGram", "myContentTextNGram");
    /*
		 * Handle _text parameter (resource narrative content)
		 */
    List<List<IQueryParameterType>> textAndTerms = theParams.remove(Constants.PARAM_TEXT);
    addTextSearch(qb, bool, textAndTerms, "myNarrativeText", "myNarrativeTextEdgeNGram", "myNarrativeTextNGram");
    if (theReferencingPid != null) {
        bool.must(qb.keyword().onField("myResourceLinksField").matching(theReferencingPid.toString()).createQuery());
    }
    if (bool.isEmpty()) {
        return pids;
    }
    if (isNotBlank(theResourceName)) {
        bool.must(qb.keyword().onField("myResourceType").matching(theResourceName).createQuery());
    }
    Query luceneQuery = bool.createQuery();
    // wrap Lucene query in a javax.persistence.SqlQuery
    FullTextQuery jpaQuery = em.createFullTextQuery(luceneQuery, ResourceTable.clreplaced);
    jpaQuery.setProjection("myId");
    // execute search
    List<?> result = jpaQuery.getResultList();
    ArrayList<ResourcePersistentId> retVal = new ArrayList<>();
    for (Object object : result) {
        Object[] nextArray = (Object[]) object;
        Long next = (Long) nextArray[0];
        if (next != null) {
            retVal.add(new ResourcePersistentId(next));
        }
    }
    return retVal;
}

13 View Complete Implementation : HikeQueryTest.java
Copyright Apache License 2.0
Author : hibernate
@Test
public void canSearchUsingFullTextQuery() {
    EnreplacedyManager enreplacedyManager = enreplacedyManagerFactory.createEnreplacedyManager();
    enreplacedyManager.getTransaction().begin();
    // Add full-text superpowers to any EnreplacedyManager:
    FullTextEnreplacedyManager ftem = Search.getFullTextEnreplacedyManager(enreplacedyManager);
    // Optionally use the QueryBuilder to simplify Query definition:
    QueryBuilder b = ftem.getSearchFactory().buildQueryBuilder().forEnreplacedy(Hike.clreplaced).get();
    // A lucene query to look for hike to the Carisbrooke castle:
    // Note that the query looks for "cariboke" instead of "Carisbrooke"
    Query lq = b.keyword().onField("description").matching("carisbroke castle").createQuery();
    // Transform the Lucene Query in a JPA Query:
    FullTextQuery ftQuery = ftem.createFullTextQuery(lq, Hike.clreplaced);
    // This is a requirement when using Hibernate OGM instead of ORM:
    ftQuery.initializeObjectsWith(ObjectLookupMethod.SKIP, DatabaseRetrievalMethod.FIND_BY_ID);
    // List matching hikes
    List<Hike> hikes = ftQuery.getResultList();
    replacedertThat(hikes).onProperty("description").containsOnly("Exploring Carisbrooke Castle");
    enreplacedyManager.getTransaction().commit();
    enreplacedyManager.close();
}

13 View Complete Implementation : LocalCacheMassIndexerTest.java
Copyright Apache License 2.0
Author : infinispan
protected void verifyFindsPerson(int expectedCount, String name) throws Exception {
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder carQueryBuilder = searchManager.buildQueryBuilderForClreplaced(Person.clreplaced).get();
    Query fullTextQuery = carQueryBuilder.keyword().onField("name").matching(name).createQuery();
    CacheQuery<Car> cacheQuery = searchManager.getQuery(fullTextQuery, Person.clreplaced);
    replacedertEquals(expectedCount, cacheQuery.getResultSize());
}

12 View Complete Implementation : HibernateSearchAtopOgmTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
@Test
public void testHibernateSearchNativeAPIUsage() throws Exception {
    final EnreplacedyManager enreplacedyManager = getFactory().createEnreplacedyManager();
    final FullTextSession ftSession = org.hibernate.search.Search.getFullTextSession(enreplacedyManager.unwrap(Session.clreplaced));
    enreplacedyManager.getTransaction().begin();
    final Insurance insurance = new Insurance();
    insurance.setName("Macif");
    ftSession.persist(insurance);
    enreplacedyManager.getTransaction().commit();
    ftSession.clear();
    enreplacedyManager.getTransaction().begin();
    final QueryBuilder b = ftSession.getSearchFactory().buildQueryBuilder().forEnreplacedy(Insurance.clreplaced).get();
    final Query lq = b.keyword().onField("name").matching("Macif").createQuery();
    final org.hibernate.search.FullTextQuery ftQuery = ftSession.createFullTextQuery(lq, Insurance.clreplaced);
    final List<Insurance> resultList = ftQuery.list();
    replacedertThat(getFactory().getPersistenceUnitUtil().isLoaded(resultList.get(0))).isTrue();
    replacedertThat(resultList).hreplacedize(1);
    for (Object e : resultList) {
        ftSession.delete(e);
    }
    enreplacedyManager.getTransaction().commit();
    enreplacedyManager.close();
}

12 View Complete Implementation : DistributedMassIndexingTest.java
Copyright Apache License 2.0
Author : infinispan
protected void verifyFindsCar(Cache cache, int expectedCount, String carMake) throws Exception {
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder carQueryBuilder = searchManager.buildQueryBuilderForClreplaced(Car.clreplaced).get();
    Query fullTextQuery = carQueryBuilder.keyword().onField("make").matching(carMake).createQuery();
    CacheQuery<Car> cacheQuery = searchManager.getQuery(fullTextQuery, Car.clreplaced);
    replacedertEquals(expectedCount, cacheQuery.getResultSize());
}

12 View Complete Implementation : PerfTest.java
Copyright Apache License 2.0
Author : infinispan
private void verifyFindsCar(Cache cache, int expectedCount, String carMake) {
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder carQueryBuilder = searchManager.buildQueryBuilderForClreplaced(Car.clreplaced).get();
    Query fullTextQuery = carQueryBuilder.keyword().onField("make").matching(carMake).createQuery();
    CacheQuery<?> cacheQuery = searchManager.getQuery(fullTextQuery, Car.clreplaced);
    replacedertEquals(expectedCount, cacheQuery.getResultSize());
}

12 View Complete Implementation : FulltextSearchSvcImpl.java
Copyright Apache License 2.0
Author : jamesagnew
@Transactional()
@Override
public List<Suggestion> suggestKeywords(String theContext, String theSearchParam, String theText, RequestDetails theRequest) {
    Validate.notBlank(theContext, "theContext must be provided");
    Validate.notBlank(theSearchParam, "theSearchParam must be provided");
    Validate.notBlank(theText, "theSearchParam must be provided");
    long start = System.currentTimeMillis();
    String[] contextParts = StringUtils.split(theContext, '/');
    if (contextParts.length != 3 || "Patient".equals(contextParts[0]) == false || "$everything".equals(contextParts[2]) == false) {
        throw new InvalidRequestException("Invalid context: " + theContext);
    }
    ResourcePersistentId pid = myIdHelperService.translateForcedIdToPid(contextParts[0], contextParts[1], theRequest);
    FullTextEnreplacedyManager em = org.hibernate.search.jpa.Search.getFullTextEnreplacedyManager(myEnreplacedyManager);
    QueryBuilder qb = em.getSearchFactory().buildQueryBuilder().forEnreplacedy(ResourceTable.clreplaced).get();
    Query textQuery = qb.phrase().withSlop(2).onField("myContentText").boostedTo(4.0f).andField("myContentTextEdgeNGram").boostedTo(2.0f).andField("myContentTextNGram").boostedTo(1.0f).andField("myContentTextPhonetic").boostedTo(0.5f).sentence(theText.toLowerCase()).createQuery();
    Query query = qb.bool().must(qb.keyword().onField("myResourceLinksField").matching(pid.toString()).createQuery()).must(textQuery).createQuery();
    FullTextQuery ftq = em.createFullTextQuery(query, ResourceTable.clreplaced);
    ftq.setProjection("myContentText");
    ftq.setMaxResults(20);
    List<?> resultList = ftq.getResultList();
    List<Suggestion> suggestions = Lists.newArrayList();
    for (Object next : resultList) {
        Object[] nextAsArray = (Object[]) next;
        String nextValue = (String) nextAsArray[0];
        try {
            MySuggestionFormatter formatter = new MySuggestionFormatter(theText, suggestions);
            Scorer scorer = new QueryScorer(textQuery);
            Highlighter highlighter = new Highlighter(formatter, scorer);
            replacedyzer replacedyzer = em.getSearchFactory().getreplacedyzer(ResourceTable.clreplaced);
            formatter.setreplacedyzer("myContentTextPhonetic");
            highlighter.getBestFragments(replacedyzer.tokenStream("myContentTextPhonetic", nextValue), nextValue, 10);
            formatter.setreplacedyzer("myContentTextNGram");
            highlighter.getBestFragments(replacedyzer.tokenStream("myContentTextNGram", nextValue), nextValue, 10);
            formatter.setFindPhrasesWith();
            formatter.setreplacedyzer("myContentTextEdgeNGram");
            highlighter.getBestFragments(replacedyzer.tokenStream("myContentTextEdgeNGram", nextValue), nextValue, 10);
        } catch (Exception e) {
            throw new InternalErrorException(e);
        }
    }
    Collections.sort(suggestions);
    Set<String> terms = Sets.newHashSet();
    for (Iterator<Suggestion> iter = suggestions.iterator(); iter.hasNext(); ) {
        String nextTerm = iter.next().getTerm().toLowerCase();
        if (!terms.add(nextTerm)) {
            iter.remove();
        }
    }
    long delay = System.currentTimeMillis() - start;
    ourLog.info("Provided {} suggestions for term {} in {} ms", terms.size(), theText, delay);
    return suggestions;
}

12 View Complete Implementation : ArtifactDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
private FullTextQuery getSearchByNameQuery(String searchTerm, ArtifactDeprecationStatus deprecation) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(getEnreplacedyManager());
    QueryBuilder artifactQueryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Artifact.clreplaced).get();
    BooleanJunction<?> booleanJunction = artifactQueryBuilder.bool();
    if (deprecation != null) {
        booleanJunction.must(artifactQueryBuilder.keyword().onField(Binding.artifact().deprecationStatus().getPath()).matching(deprecation).createQuery());
    }
    if (StringUtils.hasText(searchTerm)) {
        booleanJunction.must(artifactQueryBuilder.keyword().fuzzy().withPrefixLength(1).withThreshold(0.8F).onField(Binding.artifact().artifactId().getPath()).andField(Binding.artifact().group().groupId().getPath()).matching(searchTerm).createQuery());
    } else {
        booleanJunction.must(artifactQueryBuilder.all().createQuery());
    }
    return fullTextEnreplacedyManager.createFullTextQuery(booleanJunction.createQuery(), Artifact.clreplaced);
}

11 View Complete Implementation : BookManager.java
Copyright GNU General Public License v3.0
Author : adrianmilne
/**
 * Search for a Book.
 */
@SuppressWarnings("unchecked")
@Transactional
public List<Book> search(BookCategory category, String searchString) {
    LOG.info("------------------------------------------");
    LOG.info("Searching Books in category '" + category + "' for phrase '" + searchString + "'");
    // Create a Query Builder
    QueryBuilder qb = getFullTextEnreplacedyManager().getSearchFactory().buildQueryBuilder().forEnreplacedy(Book.clreplaced).get();
    // Create a Lucene Full Text Query
    org.apache.lucene.search.Query luceneQuery = qb.bool().must(qb.keyword().onFields("replacedle", "description").matching(searchString).createQuery()).must(qb.keyword().onField("category").matching(category).createQuery()).createQuery();
    Query fullTextQuery = getFullTextEnreplacedyManager().createFullTextQuery(luceneQuery, Book.clreplaced);
    // Run Query and print out results to console
    List<Book> result = (List<Book>) fullTextQuery.getResultList();
    // Log the Results
    LOG.info("Found Matching Books :" + result.size());
    for (Book b : result) {
        LOG.info(" - " + b);
    }
    return result;
}

11 View Complete Implementation : SharedIndexTest.java
Copyright Apache License 2.0
Author : infinispan
private void verifyResult(FullTextSessionBuilder node) {
    FullTextSession fullTextSession = node.openFullTextSession();
    try {
        Transaction transaction = fullTextSession.beginTransaction();
        QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEnreplacedy(Toaster.clreplaced).get();
        Query query = queryBuilder.keyword().onField("serialNumber").matching("A1").createQuery();
        List list = fullTextSession.createFullTextQuery(query).getResultList();
        replacedertEquals(1, list.size());
        Device device = (Device) list.get(0);
        replacedertEquals("GE", device.manufacturer);
        transaction.commit();
    } finally {
        fullTextSession.close();
    }
}

11 View Complete Implementation : LuceneQueryMaker.java
Copyright Apache License 2.0
Author : infinispan
@Override
public Query visit(FullTextTermExpr fullTextTermExpr) {
    PropertyValueExpr propertyValueExpr = (PropertyValueExpr) fullTextTermExpr.getChild();
    String text = fullTextTermExpr.getTerm();
    int asteriskPos = text.indexOf(LUCENE_MULTIPLE_CHARACTERS_WILDCARD);
    int questionPos = text.indexOf(LUCENE_SINGLE_CHARACTER_WILDCARD);
    if (asteriskPos == -1 && questionPos == -1) {
        if (isMulreplacedermText(propertyValueExpr.getPropertyPath(), text)) {
            // phrase query
            PhraseContext phrase = queryBuilder.phrase();
            if (fullTextTermExpr.getFuzzySlop() != null) {
                phrase = phrase.withSlop(fullTextTermExpr.getFuzzySlop());
            }
            return phrase.onField(propertyValueExpr.getPropertyPath().replacedtringPath()).sentence(text).createQuery();
        } else {
            // just a single term
            if (fullTextTermExpr.getFuzzySlop() != null) {
                // fuzzy query
                return applyFieldBridge(true, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().fuzzy().withEditDistanceUpTo(fullTextTermExpr.getFuzzySlop()).onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(text).createQuery();
            }
            // term query
            return applyFieldBridge(true, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(text).createQuery();
        }
    } else {
        if (fullTextTermExpr.getFuzzySlop() != null) {
            throw CONTAINER.getPrefixWildcardOrRegexpQueriesCannotBeFuzzy(fullTextTermExpr.toQueryString());
        }
        if (questionPos == -1 && asteriskPos == text.length() - 1) {
            // term prefix query
            String prefix = text.substring(0, text.length() - 1);
            return new PrefixQuery(new Term(propertyValueExpr.getPropertyPath().replacedtringPath(), prefix));
        }
        // wildcard query
        return applyFieldBridge(true, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().wildcard().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(text).createQuery();
    }
}

11 View Complete Implementation : IndexedCacheRestartTest.java
Copyright Apache License 2.0
Author : infinispan
private static void replacedertFindBook(Cache<?, ?> cache) {
    SearchManager searchManager = Search.getSearchManager(cache);
    QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClreplaced(Book.clreplaced).get();
    Query luceneQuery = queryBuilder.keyword().onField("replacedle").matching("infinispan").createQuery();
    CacheQuery<Book> cacheQuery = searchManager.getQuery(luceneQuery);
    List<Book> list = cacheQuery.list();
    replacedertEquals(1, list.size());
}

11 View Complete Implementation : ArtifactDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
@Override
public List<Artifact> searchAutocomplete(String searchPattern, Integer limit, Integer offset) throws ServiceException {
    String[] searchFields = new String[] { Binding.artifact().artifactId().getPath(), Binding.artifact().group().groupId().getPath() };
    QueryBuilder queryBuilder = Search.getFullTextEnreplacedyManager(getEnreplacedyManager()).getSearchFactory().buildQueryBuilder().forEnreplacedy(Artifact.clreplaced).get();
    Query luceneQuery = queryBuilder.keyword().onField(Binding.artifact().deprecationStatus().getPath()).matching(ArtifactDeprecationStatus.NORMAL).createQuery();
    List<SortField> sortFields = ImmutableList.<SortField>builder().add(new SortField(Binding.artifact().group().getPath() + '.' + ArtifactGroup.GROUP_ID_SORT_FIELD_NAME, SortField.Type.STRING)).add(new SortField(Artifact.ARTIFACT_ID_SORT_FIELD_NAME, SortField.Type.STRING)).build();
    Sort sort = new Sort(sortFields.toArray(new SortField[sortFields.size()]));
    return hibernateSearchService.searchAutocomplete(getObjectClreplaced(), searchFields, searchPattern, luceneQuery, limit, offset, sort);
}

10 View Complete Implementation : ProjectDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
private FullTextQuery getSearchByNameQuery(String searchTerm) {
    FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(getEnreplacedyManager());
    QueryBuilder projectQueryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Project.clreplaced).get();
    BooleanJunction<?> booleanJunction = projectQueryBuilder.bool();
    if (StringUtils.hasText(searchTerm)) {
        booleanJunction.must(projectQueryBuilder.keyword().fuzzy().withPrefixLength(1).withThreshold(0.8F).onField(Binding.project().name().getPath()).matching(searchTerm).createQuery());
    } else {
        booleanJunction.must(projectQueryBuilder.all().createQuery());
    }
    return fullTextEnreplacedyManager.createFullTextQuery(booleanJunction.createQuery(), Project.clreplaced);
}

9 View Complete Implementation : SimpleEntityMassIndexingTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
@Test
public void testSimpleEnreplacedyMreplacedIndexing() throws Exception {
    {
        Session session = openSession();
        Transaction transaction = session.beginTransaction();
        Insurance insurance = new Insurance();
        insurance.setName("Insurance Corporation");
        session.persist(insurance);
        transaction.commit();
        session.clear();
        session.close();
    }
    {
        purgeAll(Insurance.clreplaced);
        startAndWaitMreplacedIndexing(Insurance.clreplaced);
    }
    {
        FullTextSession session = Search.getFullTextSession(openSession());
        QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEnreplacedy(Insurance.clreplaced).get();
        Query luceneQuery = queryBuilder.keyword().wildcard().onField("name").matching("ins*").createQuery();
        Transaction transaction = session.beginTransaction();
        @SuppressWarnings("unchecked")
        List<Insurance> list = session.createFullTextQuery(luceneQuery).list();
        replacedertThat(list).hreplacedize(1);
        replacedertThat(list.get(0).getName()).isEqualTo("Insurance Corporation");
        transaction.commit();
        session.clear();
        session.close();
    }
}

9 View Complete Implementation : SimpleEntityMassIndexingTest.java
Copyright GNU Lesser General Public License v2.1
Author : hibernate
@Test
@SkipByGridDialect(value = { MONGODB }, comment = "Uses embedded key which is currently not supported by the db query parsers")
public void testEnreplacedyWithCompositeIdMreplacedIndexing() throws Exception {
    {
        Session session = openSession();
        Transaction transaction = session.beginTransaction();
        IndexedNews news = new IndexedNews(new NewsID("replacedle", "author"), "content");
        session.persist(news);
        transaction.commit();
        session.clear();
        session.close();
    }
    {
        purgeAll(IndexedNews.clreplaced);
        startAndWaitMreplacedIndexing(IndexedNews.clreplaced);
    }
    {
        // replacedert index creation
        FullTextSession session = Search.getFullTextSession(openSession());
        QueryBuilder queryBuilder = session.getSearchFactory().buildQueryBuilder().forEnreplacedy(IndexedNews.clreplaced).get();
        Query luceneQuery = queryBuilder.keyword().wildcard().onField("newsId").ignoreFieldBridge().matching("replaced*").createQuery();
        Transaction transaction = session.beginTransaction();
        @SuppressWarnings("unchecked")
        List<IndexedNews> list = session.createFullTextQuery(luceneQuery).list();
        replacedertThat(list).hreplacedize(1);
        replacedertThat(list.get(0).getContent()).isEqualTo("content");
        replacedertThat(list.get(0).getNewsId().getreplacedle()).isEqualTo("replacedle");
        replacedertThat(list.get(0).getNewsId().getAuthor()).isEqualTo("author");
        transaction.commit();
        session.clear();
        session.close();
    }
}

9 View Complete Implementation : TwoNodesTest.java
Copyright Apache License 2.0
Author : infinispan
private void verifyNodeSeesUpdatedIndex(FullTextSessionBuilder node) {
    FullTextSession fullTextSession = node.openFullTextSession();
    try {
        Transaction transaction = fullTextSession.beginTransaction();
        QueryBuilder queryBuilder = fullTextSession.getSearchFactory().buildQueryBuilder().forEnreplacedy(SimpleEmail.clreplaced).get();
        Query query = queryBuilder.keyword().onField("message").matching("Hibernate Getting Started").createQuery();
        List list = fullTextSession.createFullTextQuery(query).setProjection("message").getResultList();
        replacedertEquals(1, list.size());
        Object[] result = (Object[]) list.get(0);
        replacedertEquals(messageText, result[0]);
        transaction.commit();
    } finally {
        fullTextSession.close();
    }
}

9 View Complete Implementation : LuceneQueryMaker.java
Copyright Apache License 2.0
Author : infinispan
@Override
public Query visit(ComparisonExpr comparisonExpr) {
    PropertyValueExpr propertyValueExpr = (PropertyValueExpr) comparisonExpr.getLeftChild();
    ConstantValueExpr constantValueExpr = (ConstantValueExpr) comparisonExpr.getRightChild();
    Comparable value = constantValueExpr.getConstantValueAs(propertyValueExpr.getPrimitiveType(), namedParameters);
    switch(comparisonExpr.getComparisonType()) {
        case NOT_EQUAL:
            Query q = applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(value).createQuery();
            return queryBuilder.bool().must(q).not().createQuery();
        case EQUAL:
            return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.keyword().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).matching(value).createQuery();
        case LESS:
            return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.range().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).below(value).excludeLimit().createQuery();
        case LESS_OR_EQUAL:
            return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.range().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).below(value).createQuery();
        case GREATER:
            return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.range().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).above(value).excludeLimit().createQuery();
        case GREATER_OR_EQUAL:
            return applyFieldBridge(false, propertyValueExpr.getPropertyPath(), queryBuilder.range().onField(propertyValueExpr.getPropertyPath().replacedtringPath())).above(value).createQuery();
        default:
            throw new IllegalStateException("Unexpected comparison type: " + comparisonExpr.getComparisonType());
    }
}

9 View Complete Implementation : ArtifactDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
@Override
public List<Artifact> searchAutocompleteWithoutProject(String searchPattern, Integer limit, Integer offset) throws ServiceException {
    String[] searchFields = new String[] { Binding.artifact().artifactId().getPath(), Binding.artifact().group().groupId().getPath() };
    QueryBuilder queryBuilder = Search.getFullTextEnreplacedyManager(getEnreplacedyManager()).getSearchFactory().buildQueryBuilder().forEnreplacedy(Artifact.clreplaced).get();
    Query notDeprecatedQuery = queryBuilder.keyword().onField(Binding.artifact().deprecationStatus().getPath()).matching(ArtifactDeprecationStatus.NORMAL).createQuery();
    Query withoutProjectQuery = queryBuilder.keyword().onField(Binding.artifact().project().getPath()).matching(null).createQuery();
    BooleanJunction<?> booleanJunction = queryBuilder.bool().must(notDeprecatedQuery).must(withoutProjectQuery);
    List<SortField> sortFields = ImmutableList.<SortField>builder().add(new SortField(Binding.artifact().group().getPath() + '.' + ArtifactGroup.GROUP_ID_SORT_FIELD_NAME, SortField.Type.STRING)).add(new SortField(Artifact.ARTIFACT_ID_SORT_FIELD_NAME, SortField.Type.STRING)).build();
    Sort sort = new Sort(sortFields.toArray(new SortField[sortFields.size()]));
    return hibernateSearchService.searchAutocomplete(getObjectClreplaced(), searchFields, searchPattern, booleanJunction.createQuery(), limit, offset, sort);
}

9 View Complete Implementation : ArtifactDaoImpl.java
Copyright Apache License 2.0
Author : openwide-java
private FullTextQuery getSearchRecommendedQuery(String searchTerm) throws ServiceException {
    if (!StringUtils.hasText(searchTerm)) {
        return null;
    }
    FullTextEnreplacedyManager fullTextEnreplacedyManager = Search.getFullTextEnreplacedyManager(getEnreplacedyManager());
    QueryBuilder artifactQueryBuilder = fullTextEnreplacedyManager.getSearchFactory().buildQueryBuilder().forEnreplacedy(Artifact.clreplaced).get();
    BooleanJunction<?> booleanJunction = artifactQueryBuilder.bool();
    booleanJunction.must(artifactQueryBuilder.keyword().onField(Binding.artifact().deprecationStatus().getPath()).matching(ArtifactDeprecationStatus.NORMAL).createQuery());
    try {
        searchTerm = LuceneUtils.getSimilarityQuery(searchTerm, 2);
        String[] fields = new String[] { Binding.artifact().artifactId().getPath(), Binding.artifact().group().groupId().getPath() };
        replacedyzer replacedyzer = Search.getFullTextEnreplacedyManager(getEnreplacedyManager()).getSearchFactory().getreplacedyzer(Artifact.clreplaced);
        MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, replacedyzer);
        parser.setDefaultOperator(MultiFieldQueryParser.AND_OPERATOR);
        BooleanQuery booleanQuery = new BooleanQuery();
        booleanQuery.add(parser.parse(searchTerm), BooleanClause.Occur.MUST);
        booleanJunction.must(booleanQuery);
    } catch (ParseException e) {
        throw new ServiceException(String.format("Error parsing request: %1$s", searchTerm), e);
    }
    return fullTextEnreplacedyManager.createFullTextQuery(booleanJunction.createQuery(), Artifact.clreplaced);
}

9 View Complete Implementation : SearchIndexServiceBean.java
Copyright GNU Affero General Public License v3.0
Author : StadtBern
/**
 * creats a 'subquery' for the given search term and returns it.
 */
private Query createTermquery(String currSearchTerm, SearchFilter filter, QueryBuilder qb) {
    // manche felder sollen ohne field bridge matched werden, daher hier die komplizierte aufteilung
    List<String> normalFieldsToSearch = new ArrayList<>(filter.getFieldsToSearch().length);
    List<String> fieldsIgnoringBridge = new ArrayList<>();
    for (IndexedEBEGUFieldName indexedField : filter.getFieldsToSearch()) {
        if (!indexedField.isIgnoreFieldBridgeInQuery()) {
            normalFieldsToSearch.add(indexedField.getIndexedFieldName());
        } else {
            // geburtsdatum ignoriert field-bridge
            fieldsIgnoringBridge.add(indexedField.getIndexedFieldName());
        }
    }
    TermMatchingContext termCtxt = qb.keyword().wildcard().onFields(normalFieldsToSearch.toArray(new String[normalFieldsToSearch.size()]));
    for (String s : fieldsIgnoringBridge) {
        termCtxt = termCtxt.andField(s).ignoreFieldBridge();
    }
    TermTermination matching = termCtxt.matching(currSearchTerm);
    return matching.createQuery();
}