Apache Solr Facet搜索排除空间 [英] Apache Solr facet search exclude space

查看:90
本文介绍了Apache Solr Facet搜索排除空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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

但是结果让我们假设我在make字段中有"Ford Fiesta".我得到两个结果而不是一个结果,如下所示:

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

它是逐个字段分隔的.

我想要

Ford Fiesta => 21

请让我知道这样做的有效方法.

Please let me know the valid method to do so.

谢谢

推荐答案

问题在这里非常简单.您正在尝试标记化字段(文本).这意味着每个令牌将被分别计数.我建议您添加新字段(在schema.xml文件中),并使用与字段Make相同的数据来填充(例如,使用复制字段).此新字段应该是带有KeywordTokenizer的字符串或文本.

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.

请看下面的例子.我在那里添加了两种类型:字符串和text_not_tokenized.然后定义两个字段Make_string和Make_nonTokenized.当您对它们中的每一个进行刻面时,您应该会看到福特嘉年华"

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"

所以您只需查询

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

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">
....

这篇关于Apache Solr Facet搜索排除空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆