2017-12-19 8 views
0

date이라는 Solr 필드가 있고 유형은 pdate이고 다음 형식은 2017-12-19T06:45:00Z입니다. 내가 정렬 ASC와 쿼리를 실현할 때Solr에서 날짜 필드를 정렬하는 방법?

은 그 때 나는 SOLR이 오류가 나타날 수

예상치 못한 docvalues ​​필드 '날짜'(예상 = 숫자)에 대한

내가 시도 SORTED_NUMERIC을 입력 유형 및 모든 매개 변수를 변경하여이를 해결하지만 아무 것도 작동하지 않습니다.

누군가의 아이디어가 있으십니까?

감사합니다.

+0

당신이 SOLR를 업그레이드/유형을 변경 한 후 다시 색인 적이 있습니까? – MatsLindh

답변

0

config.xml 파일에 날짜 유형 필드를 정의하면됩니다.

<field name="publishedon" type="date" multiValued="false" indexed="true" stored="true" docValues="true"/> 

그럼 당신은 이런이 정의 필드에 정렬을 적용 할 수 있습니다

public Page<Article> getArticles(final String querySolr, final Pageable page) { 
    Query querySolrObj = new SimpleQuery(querySolr); 
    Sort publishedOnSorting = new Sort(Direction.ASC, "publishedon"); 
    querySolrObj.addSort(publishedOnSorting); 
    querySolrObj.setPageRequest(page); 
    Page<ArticleSE> result = executeNativeQuery(querySolrObj);  
    return result; 
}