我在solr文件中有五个字段。
startDate---> Date type
endDate----> Date type
name -----> string type
location ----> string type
publishDate ----> Date type
现在我想按此顺序对此文档进行排序
我正在使用solrj api,为此我正在使用
solrQuery.setSort("startdate", SolrQuery.ORDER.asc)
solrQuery.addSort("enddate", SolrQuery.ORDER.asc)
solrQuery.addSort("name", SolrQuery.ORDER.asc)
solrQuery.addSort("location", SolrQuery.ORDER.asc)
solrQuery.addSort("publish_date", SolrQuery.ORDER.asc)
但它不起作用请帮忙
schema.xml:
<field name="startdate" type="tdate"
indexed="true" stored="true"/>
<field name="enddate" type="tdate" indexed="true" stored="true"/>
<field name="publish_date" type="tdate" indexed="true"
stored="true"/>
<field name="location" type="text_general_edge_nGram"
indexed="true" stored="true"/>
<fieldType name="tdate" class="solr.TrieDateField"
precisionStep="6" positionIncrementGap="0"/>
<fieldType name="text_general_edge_nGram" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" />
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2"
maxGramSize="30" side="front" luceneMatchVersion="4.3"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true"
words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory"
synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
答案 0 :(得分:2)
我认为它来自你的tokenizer,它产生一个多值字段。 除非您使用生成单个术语的分析器,否则您将无法对该字段进行排序。
https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters
http://atpatil.blogspot.fr/2014/07/Solr-sort-strings.html
difference between StandardTokenizerFactory and KeywordTokenizerFactory in SoLR