首页 文章

使用“字符串”字段,“文本”字段和“复制”字段与Solr对齐

提问于
浏览
8

我有Solr和Faceting的问题,并想知道是否有人知道修复 . 我现在有一个解决方法,但我真的想知道为什么我的查询不起作用 .

这是我的Schema,简化为更容易理解:

<fields>
    <field name="uniqueid" type="string" indexed="true" required="true"/>
    <!-- Indexed and Stored Field --->
    <field name="recordtype" type="text" indexed="true" stored="true"/>
    <!-- Facet Version of fields -->
    <field name="frecordtype" type="string" indexed="true" stored="false"/>
</fields>

<!-- Copy fields for facet searches -->
<copyField source="recordtype" dest="frecordtype"/>

正如您所看到的,我有一个名为recordtype的不区分大小写的字段,它被复制到区分大小写的字段frecordtype,它不会对文本进行标记 . 这是因为solr在分面结果中返回索引值而不是存储值 .

当我尝试以下查询时:

http://localhost:8080
/solr
/select
?version=2.2
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype
&facet=on
&fq=%7b!tag%3dfrecordtype%7dfrecordtype%3aLarge%20Record
&f1=*%2cscore
&rows=20
&start=0
&qt=standard
&q=text%3a%25

我没有得到任何结果,但是设备仍然显示有1条记录 .

<result name="response" numFound="0" start="0" /> 
 <lst name="facet_counts">
  <lst name="facet_queries" /> 
 <lst name="facet_fields">
 <lst name="frecordtype">
  <int name="Large Record">1</int> 
  <int name="Small Record">12</int> 
  <int name="Other">1</int> 
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  </lst>

但是,如果我将fitler查询(仅限第7行)更改为frecordtype的“recordtype”:

http://localhost:8080
/solr
/select
?version=2.2
&facet.field=%7b!ex%3dfrecordtype%7dfrecordtype
&facet=on
&fq=%7b!tag%3dfrecordtype%7drecordtype%3aLarge%20Record
&f1=*%2cscore
&rows=20
&start=0
&qt=standard
&q=text%3a%25

我得到了我想要的1个结果 .

<result name="response" numFound="1" start="0" /> 
 <lst name="facet_counts">
  <lst name="facet_queries" /> 
 <lst name="facet_fields">
 <lst name="frecordtype">
  <int name="Large Record">1</int> 
  <int name="Small Record">12</int> 
  <int name="Other">1</int> 
  </lst>
  </lst>
  <lst name="facet_dates" /> 
  </lst>

所以我的问题是,为了获得第一个版本的查询以返回我想要的结果,我需要做些什么吗?也许这与URL编码或其他什么有关?一些solr guru或其他人的任何提示都会非常感激 .

注意:这不是一个分面问题,因为分面实际上是有效的 . 它更像是一个查询问题,因为我无法对“字符串”字段执行查询,即使案例和间距与索引版本完全相同 .

编辑:有关分面的更多信息,您可以查看这些博客文章:

谢谢

戴夫

1 回答

  • 10

    您需要围绕值的引号

    例如 .

    frecordtype:“大记录”

    作品

    frecordtype:大记录

    这将在frecordtype中搜索Large,这将返回任何内容..然后在solr中的默认字段中进行记录 .

相关问题