dongpo5239 2014-12-05 12:46
浏览 48
已采纳

Apache Solr构面搜索排除空间

I am using Apache Solr and using following Query for search

http://Siteurl:8080/solr/metro/select?q=*:*&rows=0&wt=json&indent=true&facet=true&facet.field=Make

But as result let suppose I have 'Ford Fiesta' in make field. I am getting two results instead of one as shown below :

Ford => 21
Fiesta => 21

It is seprating field by space.

I want it like

Ford Fiesta => 21

Please let me know the valid method to do so.

Thanks

  • 写回答

1条回答 默认 最新

  • doushang1964 2014-12-05 16:39
    关注

    The problem is very simple here. You are trying to facet on tokenized field (text). This means each token will be counted separately. I suggest you to add new field (in schema.xml file) which you will feed with the same data as field Make (eg. using copy field). This new field should be string or text with KeywordTokenizer.

    Please look at the example below. I added there two types: string and text_not_tokenized. Then defined two fields Make_string and Make_nonTokenized. When you facet on each of them you should see "Ford Fiesta"

    So you can just query

    http://Siteurl:8080/solr/metro/select?q=*:*&rows=0&wt=json&indent=true&facet=true&facet.field=Make_string
    

    or

    http://Siteurl:8080/solr/metro/select?q=*:*&rows=0&wt=json&indent=true&facet=true&facet.field=Make_nonTokenized
    

    .

    ...
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
    <fieldType name="text_not_tokenized" class="solr.TextField">
      <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
      </analyzer>
    </fieldType>
    ...
    <field name="Make_string" type="string">
    <field name="Make_nonTokenized" type="text_not_tokenized">
    ....
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?