2016-05-15 60 views
1

我修改了techproducts示例以更多地瞭解同義詞。添加的字段有text2_deSolr:同義詞的精確查詢語法?

<fieldType name="text2_de" class="solr.TextField" positionIncrementGap="100"> 
    <analyzer type="index"> 
     <tokenizer class="solr.ClassicTokenizerFactory"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
     <filter class="solr.StopFilterFactory" format="snowball" words="lang/stopwords_de.txt" ignoreCase="true"/> 
     <filter class="solr.SynonymFilterFactory" expand="true" ignoreCase="true" synonyms="index_synonyms.txt"/> 
    </analyzer> 
    <analyzer type="query"> 
     <tokenizer class="solr.ClassicTokenizerFactory"/> 
     <filter class="solr.LowerCaseFilterFactory"/> 
    </analyzer> 

的index_synonyms.txt由開始的水平分層同義詞擴大了小面的類型根據https://wiki.apache.org/solr/HierarchicalFaceting

aaafoo => aaabar 
bbbfoo => bbbfoo bbbbar 
cccfoo => cccbar cccbaz 
fooaaa,baraaa,bazaaa 

Umwelt => 1/HS , 2/HS/Bereich , 3/HS/Bereich/Umwelt 
Mensch => 1/HS , 2/HS/Bereich , 3/HS/Bereich/Mensch 
... 

的加載項的信息顯示,該分析儀工作得非常好並在文件集中找到60x「2/hs/bereich」。

loaded term info for the testfield

我不能做一個Solr的查詢找到這些60份文件。加載的項信息的自動生成的超級鏈接

http://localhost:8983/solr/#/test/query?q=testfield:2%2Fhs%2Fbereich 

沒有找到任何匹配(numFound =「0」):

<response> 
<lst name="responseHeader"> 
    <int name="status">0</int> 
    <int name="QTime">0</int> 
    <lst name="params"> 
    <str name="q">testfield:2/hs/bereich</str> 
    <str name="indent">on</str> 
    <str name="wt">xml</str> 
    <str name="_">1463321610566</str> 
    </lst> 
</lst> 
<result name="response" numFound="0" start="0"> 
</result> 
</response> 

請給我一個提示,使一個確切的Solr查詢語法同義詞找到這60個文件!

回答

0

發現的解決方案:請自動添加通配符產生在這個例子中,加載項信息的查詢:testfield:2/HS/strahlung

<response> 
<lst name="responseHeader"> 
    <int name="status">0</int> 
    <int name="QTime">24</int> 
    <lst name="params"> 
    <str name="q">*:*</str> 
    <str name="facet.field">testfield</str> 
    <str name="indent">on</str> 
    <str name="facet.prefix">3/hs/strahlung</str> 
    <str name="fq">testfield:*2/hs/strahlung*</str> 
    <str name="rows">0</str> 
    <str name="facet">on</str> 
    <str name="wt">xml</str> 
    <str name="_">1463590654764</str> 
    </lst> 
</lst> 
<result name="response" numFound="68" start="0"> 
</result> 
<lst name="facet_counts"> 
    <lst name="facet_queries"/> 
    <lst name="facet_fields"> 
    <lst name="testfield"> 
     <int name="3/hs/strahlung/neutronen">44</int> 
     <int name="3/hs/strahlung/wirkung">37</int> 
     <int name="3/hs/strahlung/strahlensschutz">34</int> 
     <int name="3/hs/strahlung/exposition">22</int> 
     <int name="3/hs/strahlung/radioaktivitaet">22</int> 
     <int name="3/hs/strahlung/radiologisch">12</int> 
     <int name="3/hs/strahlung/strahlenart">7</int> 
    </lst> 
    </lst> 
    <lst name="facet_ranges"/> 
    <lst name="facet_intervals"/> 
    <lst name="facet_heatmaps"/> 
</lst> 
</response> 

在組合與facet.prefix 3/hs/strahlung有可能深入挖掘層次同義詞的問題。