Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 如何在Solr中查询where条件?_Spring Mvc_Solr_Spring Data Solr - Fatal编程技术网

Spring mvc 如何在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

我需要为search autocomplete编写一个solr查询,用户可以在其中输入产品名称或产品样式,其中竞争对手id=1,并返回竞争对手列表。 我使用了SpringDataSolr@Query注释,但无法在Solr中实现“WHERE”条件。这是我的密码:

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);