Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Solr:搜索带连字符的术语会得到0个结果_Solr_Hyphen - Fatal编程技术网

Solr:搜索带连字符的术语会得到0个结果

Solr:搜索带连字符的术语会得到0个结果,solr,hyphen,Solr,Hyphen,我无法在SOLR搜索结果中检索连字符术语。例如,当我尝试进行类似“超人”、“超人”等搜索时,我应该在搜索结果中看到类似“超人”、“超人3”等标题 字段类型如下所示: <fieldType name="autocomplete_edge" class="solr.TextField"> <analyzer type="index"> <charFilter class="solr.MappingCharFilterFactory" mappin

我无法在SOLR搜索结果中检索连字符术语。例如,当我尝试进行类似“超人”、“超人”等搜索时,我应该在搜索结果中看到类似“超人”、“超人3”等标题

字段类型如下所示:

<fieldType name="autocomplete_edge" class="solr.TextField">
    <analyzer type="index">
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" />
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="([\.,;:-_])" replacement=" " replace="all" />
        <filter class="solr.EdgeNGramFilterFactory" maxGramSize="30" minGramSize="1" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="([^\w\d\*æøåÆØÅ ])" replacement="" replace="all" />
    </analyzer>
    <analyzer type="query">
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" />
        <tokenizer class="solr.KeywordTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="([\.,;:-_])" replacement=" " replace="all" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="([^\w\d\*æøåÆØÅ ])" replacement="" replace="all" />
        <filter class="solr.PatternReplaceFilterFactory" pattern="^(.{30})(.*)?" replacement="$1" replace="all" />
    </analyzer>
</fieldType> 

请帮忙

关于

我建议在您的用例中使用

WordDelimiterFilterFactory将允许您生成可以在特殊字符和数字上拆分的标记,并保留原始标记,以便与搜索词匹配

例如,
generateWordParts
将转换
super-man
->
super-man

splitOnNumerics
将生成super-man3->
super,man,3

catenateWords
会将
超人
->
超人

catenatell
将转换为
super-man3
->
superman3


因此,这将为您提供匹配相同单词组合的能力,假设您正在标记连字符ok(请参阅下面的答案中提到的WordDelimiterFilterFactory),那么您的solr配置文件中的默认字段(df)或作为参数传递(&df=xxxx)与您标记的字段相同吗

假设默认字段为:text 您的索引字段是:name

如果我们询问超人

name:super man
实际查询是:

parsedquery_toString: "+name:super +text:man"
这不匹配。如果您在引号中查询super man:

name:"super man"
它应该工作良好,但灵活性较低:

parsedquery_toString: "name:\"super man\"",
如果将df设置为名称(例如,匹配索引字段),则会给出:

parsedquery_toString: "+name:super +name:man"
也可以直接查询

name:super name:man

注意:如果您使用的是Demax,如果仍然不匹配,您可能需要查看mm字段。

您能以更可读的格式发布字段类型吗?您好,原始问题已编辑为具有更可读格式的内容。搜索词如super,super-,superman,superman返回所需的标题。失败的例子是:结果为0的超人