我修改了techproducts示例以了解有关同义词的更多信息。添加的字段的类型为text2_de
<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&#34; 2 / hs / bereich&#34;在文档集中。
loaded term info for the testfield
我无法进行solr查询来查找这60个文档。自动生成的已加载术语信息的超链接
http://localhost:8983/solr/#/test/query?q=testfield:2%2Fhs%2Fbereich
找不到匹配项(numFound =&#34; 0&#34;):
<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 :(得分:0)
找到解决方案:请在此示例中的已加载术语信息的自动生成查询中添加通配符: testfield: 2 / hs / strahlung
controllers.addLocationCtrl = function($scope, countriesFactory, provincesFactory){
countriesFactory.getCountries().then(function(data){
$scope.countries = data;
console.log($scope.countries);
});
provincesFactory.getProvinces().then(function(data){
$scope.provinces = data;
console.log($scope.provinces);
});
}
结合facet.prefix 3 / hs / strahlung ,可以深入了解分层同义词的问题。