2017-07-04 60 views
0

我有以下索引和查詢彈簧elasticsearch濾波器術語消耗列表

@Document(indexName="idx", type="worker") 
public class Worker { 
    @Id 
    @Field(type = FieldType.Long) 
    private Long id; 
    @Field(type = FieldType.String) 
    private String firstName; 
    @Field(type = FieldType.String) 
    private String lastName; 
    --getter--setter 
} 


public interface WRepo extends ElasticsearchRepository<Worker, Long> { 

    @Query("{ 
     "query": {"match": {"firstName": "?0"}}, 
     "filter": {"terms" : {"id" : ***ids***}} 
    }") 
    Page<Worker> searchWorker(String firstName, List<Long> ids, Pageable pageable); 
} 

ID數是多變的,當加入IDS靜態像

{ 「ID」:[101,102,103 ]}

它按預期工作,我的問題是如何從方法簽名傳遞ID列表像的firstName

{ 「名字」: 「0」}

回答

0

我改變了下面

@Query("{ 
    "query": {"match": {"firstName": "?0"}}, 
    "filter": {"terms" : {"id" : [?1]}} 
}") 
Page<Worker> searchWorker(String firstName, String ids, Pageable pageable); 

方法體,使我的要求是:

repository.searchProduct("firstName", "101,102", pageable)