Spring mvc 如何在Solr中查询where条件?
我需要为search autocomplete编写一个solr查询,用户可以在其中输入产品名称或产品样式,其中竞争对手id=1,并返回竞争对手列表。 我使用了SpringDataSolr@Query注释,但无法在Solr中实现“WHERE”条件。这是我的密码:Spring mvc 如何在Solr中查询where条件?,spring-mvc,solr,spring-data-solr,Spring Mvc,Solr,Spring Data Solr,我需要为search autocomplete编写一个solr查询,用户可以在其中输入产品名称或产品样式,其中竞争对手id=1,并返回竞争对手列表。 我使用了SpringDataSolr@Query注释,但无法在Solr中实现“WHERE”条件。这是我的密码: public interface ProductRepository extends SolrCrudRepository<Product, String>{ @Query("Product_Name:*?0* OR Pro
public interface ProductRepository extends SolrCrudRepository<Product, String>{
@Query("Product_Name:*?0* OR Product_Style_No:*?0*")
public Page<Product> findByProductNameORsku(String productName, Pageable pageable);
@Query("Page_Title:?0")
public Page<Product> findByPageTitle(String pageTitle, Pageable pageable);
}
公共接口ProductRepository扩展了SolrCrudRepository{
@查询(“产品名称:?0*或产品样式:?0*”)
公共页面findByProductNameORsku(字符串产品名,可分页);
@查询(“页面标题:?0”)
公共页面findByPageTitle(字符串pageTitle,可分页Pageable);
}
我假设您不希望竞争对手id
影响文档分数。我建议使用过滤查询
@Query(value="Product_Name:*?0* OR Product_Style_No:*?0*", filters={"competitor_id:1"})
public Page<Product> findBy...
@Query(value="Product_Name:*?0* OR Product_Style_No:*?0*", filters={"competitor_id:?1"})
public Page<Product> findByPNameOrSjyFilterByCompetitor(String pname, int competitorId, Pageable pageable);