Solr多值域 - 类似的facet场

时间:2015-12-06 04:19:47

标签: solr

背景,我正在对某些文档进行一些关键短语提取。在这里,我有一个术语列表,我想用作上传文件的方面(I did this) 所以我有一份关于结肠癌的术语列表,并且出现了一个问题,其中一个方面表明有10个文件有一个特定的术语,但我得到400个文件,其中10个实际包含该术语而另外390个没有。我认为这是因为该术语特别包含另一个术语。

我正在寻找的术语:no evidence 还有另一个术语实际上出现了400次:no 同样地,我正在寻找术语:free of,它在所有文档中出现1次,但我得到31个结果。有一个术语free出现了31次。

这是我的架构:

<field name="ColonCancer" type="ColonCancer" indexed="true" stored="true" multiValued="true"
   termPositions="true"
   termVectors="true"
   termOffsets="true"/>
<fieldType name="ColonCancer" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<filter class="solr.ShingleFilterFactory"
            minShingleSize="2" maxShingleSize="5"
            outputUnigramsIfNoShingles="true"
    />
  <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms_ColonCancer.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.KeywordTokenizerFactory"/>
    <filter class="solr.KeepWordFilterFactory"
            words="prefLabels_ColonCancer.txt" ignoreCase="true"/>
  </analyzer>
</fieldType>

有没有办法让它的行为方式只能看到正确的数量(没有证据只显示10个结果)。

编辑:这似乎给了我想要的东西:

http://localhost:8983/solr/Cytokine/tvrh?q=%22no%22%20OR%20%22no%20evidence%22&fq=ColonCancer:no&fq=ColonCancer:no%20evidence&tv=true&tv.offsets=true

1 个答案:

答案 0 :(得分:0)

您可以通过多种方式解决此问题。

您可以将字段更改为字符串字段。这会将facet查询行为转换为&#34; specific&#34;。那就是 - 寻找&#34;没有证据&#34;只会找到&#34;没有证据&#34; - 区分大小写。

另一种选择是在查找特定组合时使用构面查询。 然后你可以使用~simbol强制它们之间的范围。

示例:

<field name="ColonCancer" type="ColonCancer" indexed="true" stored="true" multiValued="true"
termPositions="true"
termVectors="true"
termOffsets="true"/>

 <fieldType name="ColonCancerString" class="solr.StringField">

<analyzer>
 <filter class="solr.ShingleFilterFactory"
        minShingleSize="2" maxShingleSize="5"
        outputUnigramsIfNoShingles="true"
/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
  <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SynonymFilterFactory"     synonyms="synonyms_ColonCancer.txt" ignoreCase="true" expand="true"   tokenizerFactory="solr.KeywordTokenizerFactory"/>
     <filter class="solr.KeepWordFilterFactory"
        words="prefLabels_ColonCancer.txt" ignoreCase="true"/>
  </analyzer>
  </fieldType>
  <copyField source="ColonCancer" dest="ColonCancerString"/>

我在这里添加了另一个名为ColonCancerString的字段,它应该包含相同的文本 - 但是作为字符串。

架构中的copyFIeld行告诉它复制字段值。

请参阅此处了解复制字段线程:

How to use SOLR copyField directive