Skip to content

Commit

Permalink
STEP-3 - Use Facet Annotation for autocomplete
Browse files Browse the repository at this point in the history
Use Solr specific Facet annotation to simplify code for autocomplete.
Custom Implementation can be removed, while method signature moves to
SolrRepository.
  • Loading branch information
christophstrobl committed Apr 18, 2014
1 parent 3044165 commit 27fa1a3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.solr.core.query.Query.Operator;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.repository.Facet;
import org.springframework.data.solr.repository.Query;
import org.springframework.data.solr.repository.SolrCrudRepository;
import org.springframework.data.solr.showcase.product.model.Product;

/**
* @author Christoph Strobl
*/
interface ProductRepository extends ProductRepositoryCustom, SolrCrudRepository<Product, String> {
interface ProductRepository extends SolrCrudRepository<Product, String> {

@Query(fields = { SearchableProductDefinition.ID_FIELD_NAME, SearchableProductDefinition.NAME_FIELD_NAME,
SearchableProductDefinition.PRICE_FIELD_NAME, SearchableProductDefinition.FEATURES_FIELD_NAME,
SearchableProductDefinition.AVAILABLE_FIELD_NAME }, defaultOperator = Operator.AND)
Page<Product> findByNameIn(Collection<String> names, Pageable page);

@Facet(fields = { SearchableProductDefinition.NAME_FIELD_NAME })
FacetPage<Product> findByNameStartsWith(Collection<String> nameFragments, Pageable pagebale);

}

This file was deleted.

This file was deleted.

0 comments on commit 27fa1a3

Please sign in to comment.