实施了基本的Solr建议。我能够得到建议的条款。 但有没有办法根据建议返回整个SOLR文档?
这是solr_config.xml中的searchComponent和requestHandler。
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
<str name="field">complete_search</str>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
schema.xml中的字段和fieldType定义如下。
<field name="complete_search" type="text_auto" indexed="true" stored="true" multiValued="true"/>
<fieldType class="solr.TextField" name="text_auto">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
</fieldType>
我得到的结果如下:
<arr name="suggestion">
<str>global academy for learning</str>
<str>global art</str>
<str>global institute of fine arts</str>
<str>global kids</str>
<str>global music academy</str>
<str>global residential school</str>
<str>globetrippers</str>
<str>globetrotters</str>
<str>glorious kids</str>
<str>glow tennis academy</str>
</arr>
我的查询是http://localhost:8983/solr/core_name/suggest?q=glo
有没有办法以SOLR文件的形式获取输出,如
<doc>
<str name="id">35716</str>
<str name="PID">35716</str>
<str name="service_name">Cherubs Montessori</str>
<arr name="complete_search">
<str>Cherubs Montessori</str>
<str>Arts and Crafts</str>
<str>No 173, 9th Main Road, 7th Sector, HSR Layout</str>
<str>Bangalore</str>
<str>HSR Layout</str>
</arr>
<str name="permalink">http://zp.local/extracurricular-activities/cherubs-montessori-at-hsr-layout-in-bangalore</str>
<arr name="categories">
<str>Arts and Crafts</str>
</arr>
<float name="average_ratings">0.0</float>
<str name="lat_lng">12.9102859,77.6450215</str>
<str name="listing_thumbnail">/uploads/2015/09/Cherubs-Montessori-300x122.jpg</str>
<float name="maximum_age">14.0</float>
<float name="minimum_age">5.0</float>
<str name="address">No 173, 9th Main Road, 7th Sector, HSR Layout</str>
<str name="city">Bangalore</str>
<str name="locality">HSR Layout</str>
<long name="_version_">1514279153996660736</long></doc>
<doc>