代码之家  ›  专栏  ›  技术社区  ›  CraftyFella

使用“字符串”字段、“文本”字段和“复制”字段使用Solr进行刻面

  •  8
  • CraftyFella  · 技术社区  · 16 年前

    我对Solr和Faceting有一个问题,我想知道是否有人知道这个补丁。我现在有一个解决办法,但是我真的想弄清楚为什么我的查询不起作用。

    这是我的模式,简化后更易于遵循:

    <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
    

    <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行)更改为“recordtype”,而不是frecordtype:

    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
    

    <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大师或其他方面的提示都将非常感激。

    谢谢

    1 回复  |  直到 16 年前
        1
  •  10
  •   CraftyFella    16 年前

    例如。

    frecordtype:“大记录”

    作品

    这将在frecordtype中搜索Large,但不会返回任何内容。。然后记录solr中的默认字段。