我正在尝试使用建议器使用SOLR自动完成打字头。
将对聚合用户的用户和组名进行搜索。搜索将在用户名,生物,网页和其他内容上完成。我想要实现的是“facebook”或“twitter”类似的搜索。为此,我需要使用附加数据(用户类型,配置文件的url,他的头像URL等)来丰富SOLR的结果。
用户和组将在SOLR中具有ID字段,该字段对应于DB中的ID以获取这些信息。我被困在如何做到这一点。
目前我有建议工作,但它只返回建议值,当我尝试从文档中返回一些其他属性时它不起作用。
以下是solrconfig的一部分:
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<!-- configure the spellchecker used
for autocomplete (dictionary) -->
<lst name="spellchecker">
<str name="name">suggester_dictionary</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str>
<!-- The indexed field to derive suggestions from -->
<str name="field">autocomplete</str>
<!-- buildOnCommit must be set to true because
suggester keeps data in memory -->
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler class="solr.SearchHandler" name="/suggest">
<lst name="defaults">
<!-- by default use the suggester_dictionary -->
<str name="spellcheck.dictionary">suggester_dictionary</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.onlyMorePopular">false</str>
</lst>
<lst name="invariants">
<!-- always run the Suggester for queries to this handler -->
<str name="spellcheck">true</str>
<!-- collate not needed, query if tokenized as keyword, we need only suggestions for that term -->
<str name="spellcheck.collate">false</str>
</lst>
<!-- this handler uses only the needed component :
suggest defined above -->
<arr name="components">
<str>suggest</str>
<str>highlight</str>
</arr>
</requestHandler>
和计划:
<field name="groupid" type="int" indexed="true" stored="true"
required="true" multiValued="false"/>
<field name="groupusername" type="text_general" indexed="true"
stored="true" multiValued="true"/>
<field name="groupname" type="text_general" indexed="true"
stored="true" multiValued="false"/>
<field name="grouporuser" type="boolean" indexed="true"
stored="true" multiValued="false"/>
<field name="autocomplete" type="text_autocomplete"/>
<copyField source="groupusername" dest="autocomplete"/>
<copyField source="groupname" dest="autocomplete"/>
查询: http://gruppu.com:8983/solr/suggest?q= :&安培; spellcheck.q =乔&安培;拼写检查=真安培; HL =上&安培; hl.fl = GROUPID
回应:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="jo">
<int name="numFound">2</int>
<int name="startOffset">0</int>
<int name="endOffset">2</int>
<arr name="suggestion">
<str>jorge</str>
<str>jorgen</str>
</arr>
</lst>
</lst>
</lst>
</response>
我想返回groupid和grouporuser字段...到目前为止没有运气。
答案 0 :(得分:0)