开发者

Facet + Query on Text in order to get an autocomplete

I would like to get an auto-suggest / auto-complete fie开发者_Python百科ld in my application and I am able to get that on a string field, but faceting or querying is not "working" on a text field as on a string field, specially with spaced words.

For now my request is q=cleared_keywords:piso\%20e*&facet=on&facet.field=cleared_keywords&facet.sort=result_count&facet.mincount=1&version=2.2&start=0&rows=0&indent=on&facet.limit=10

and my schema is :

 <fields>
   <field name="id" type="integer" indexed="true" stored="true" required="true"/> 
   <field name="country" type="string" indexed="true" stored="true" required="true"/> 
   <field name="city_id" type="integer" indexed="true" stored="true" required="false"/>
   <field name="ad_type" type="integer" indexed="true" stored="true" required="true"/>
   <field name="keywords" type="text" indexed="true" stored="true" required="true"/>
   <field name="result_count" type="sint" indexed="true" stored="true" required="true"/>
   <field name="hash" type="integer" indexed="true" stored="true" required="true"/>
   <field name="cleared_keywords" type="string" indexed="true" stored="true" required="false"/>
   <field name="keywords_score" type="sfloat" indexed="true" stored="true" required="true"/>
   <field name="sorted_keywords" type="string" indexed="true" stored="true" required="true"/>
   <field name="links_to" type="integer" indexed="true" stored="true" multiValued="true"/>
   <field name="keywordsAsSuggestion" type="string" indexed="true" stored="true" />
   <dynamicField name="random*" type="rand" indexed="true" stored="true"/>
   <copyField source="keywords" dest="keywordsAsSuggestion" />
 </fields>

If I try same query on text (keywords) field it's not working because of text. I don't understand how copyField is working, do I need to reload / recreate the index ?

I wanted to skip the "recreate index" step, but if I can't I'll just load all Solr Document and recreate new ones with a String field with the keywords text field values ... I just don't like that idea.

Regards,

Alexis


The analyzers and tokenizers defined for field type text is different from that of string in the default schema.xml. If you want to try providing phrases for auto suggest, then it would be better to define your own field type with necessary analyzers and tokenizers. This gives detailed information about them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜