使用Spring SimpleFacetQuery从Solr仅获取特定字段数据的任何现成方式

时间:2019-06-24 10:54:03

标签: spring-boot solr spring-data-jpa

我有类似的文档:

MyService{id='1956462206', serviceImageId='ebngTVCzt5Y', name='Academic_Advising', endpointUrl='http://localhost:36548/', transportProtocol='HTTP', dataProtocols='Web Services (SOAP)', groupTag='workday', status='2', statusDescription='Running', registryName='tcp://localhost:2010/Registry', vseName='VSE', lastModified='02/02/2019', marFileModifiedDate='1550053068000', executionMode='Most Efficient', description='Academic_Advising', dashboardConnectionUrl='http://localhost:1506', lastRefreshedDate=06/24/2019 09:32:27, operations=[Get_Academic_Progress_for_Student_Request, Get_Academic_Advising_Notes_Request, Put_Academic_Advising_Note_Request, Get_Explored_Program_of_Study_Evaluation_Results_Request]}

现在我想获取id,名称,serviceImageId,dataProtocols和操作的数据

而且我已经编写了代码,需要根据要求进行修改。

//我尝试了这段代码,但没有用

  SimpleFacetQuery query =  new SimpleFacetQuery(conditions, new SolrPageRequest(page, size));
    query.addSort(getSortOrder(sortBy, direction));
    query.addProjectionOnFields(new String[]{"name"});
    query.setFields(new String[]{"id","name","serviceImageId","dataProtocols",""});

需要修改的现有代码

Criteria conditions = createSearchConditions(searchFields);
        conditions.and(new Criteria(SERVICE_IMAGE_ID_S_LOWER).isNotNull());
        SimpleFacetQuery query = new SimpleFacetQuery(conditions, new SolrPageRequest(page, size)).addSort(getSortOrder(sortBy, direction));

 FacetPage<VirtualService> results = solrTemplate.query(COLLECTION_NAME, query, MyService.class);

任何建议如何实现这一目标。

0 个答案:

没有答案