gpt4 book ai didi

solr - solr 搜索结果中的网址和电子邮件

转载 作者:行者123 更新时间:2023-12-04 19:16:35 29 4
gpt4 key购买 nike

我有一个 solr 搜索返回上下文突出显示结果,显示网址和电子邮件,句点后带有空格 - 例如“www.google.com”或“email@google.com”无论如何要关闭它,以便它们正常显示?谢谢。

询问:

/solr/core1/select?q=email&start=0&rows=10&sort=score+desc&fq=%28categories%3A%28*8*%29%29&wt=javabin&version=2

在配置中突出显示部分:
<searchComponent class="solr.HighlightComponent" name="highlight">
<highlighting>
<!-- Configure the standard fragmenter -->
<!-- This could most likely be commented out in the "default" case -->
<fragmenter name="gap"
default="true"
class="solr.highlight.GapFragmenter">
<lst name="defaults">
<int name="hl.fragsize">250</int>
</lst>
</fragmenter>

<!-- A regular-expression-based fragmenter
(for sentence extraction)
-->
<fragmenter name="regex"
class="solr.highlight.RegexFragmenter">
<lst name="defaults">
<!-- slightly smaller fragsizes work better because of slop -->
<int name="hl.fragsize">70</int>
<!-- allow 50% slop on fragment sizes -->
<float name="hl.regex.slop">0.5</float>
<!-- a basic sentence pattern -->
<str name="hl.regex.pattern">[-\w ,/\n\&quot;&apos;]{20,200}</str>
</lst>
</fragmenter>

<!-- Configure the standard formatter -->
<formatter name="html"
default="true"
class="solr.highlight.HtmlFormatter">
<lst name="defaults">
<str name="hl.simple.pre"><![CDATA[<b class="highlite">]]></str>
<str name="hl.simple.post"><![CDATA[</b>]]></str>
</lst>
</formatter>

<!-- Configure the standard encoder -->
<encoder name="html"
class="solr.highlight.HtmlEncoder" />

<!-- Configure the standard fragListBuilder -->
<fragListBuilder name="simple"
default="true"
class="solr.highlight.SimpleFragListBuilder"/>

<!-- Configure the single fragListBuilder -->
<fragListBuilder name="single"
class="solr.highlight.SingleFragListBuilder"/>

<!-- default tag FragmentsBuilder -->
<fragmentsBuilder name="default"
default="true"
class="solr.highlight.ScoreOrderFragmentsBuilder">
<!--
<lst name="defaults">
<str name="hl.multiValuedSeparatorChar">/</str>
</lst>
-->
</fragmentsBuilder>
</highlighting>

更新架构:
<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true">
<analyzer type="index">
<!-- <tokenizer class="solr.WhitespaceTokenizerFactory"/> -->
<tokenizer class="solr.UAX29URLEmailTokenizerFactory"/>
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<!-- Case insensitive stop word removal.
add enablePositionIncrements=true in both the index and query
analyzers to leave a 'gap' for more accurate phrase queries.
-->
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
enablePositionIncrements="true"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>

<analyzer type="query">
<!-- <tokenizer class="solr.WhitespaceTokenizerFactory"/> -->
<tokenizer class="solr.UAX29URLEmailTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.StopFilterFactory"
ignoreCase="true"
words="stopwords.txt"
enablePositionIncrements="true"
/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
</analyzer>
</fieldType>

字段
<fields>
.....
<field name="tease" type="text" indexed="false" stored="true" />
<field name="text" type="text" indexed="false" stored="true" />
<field name="fulltext" type="text" indexed="true" stored="false" multiValued="true"/>
</fields>

<copyField source="text" dest="fulltext"/>
<copyField source="title" dest="fulltext"/>
<copyField source="tease" dest="fulltext"/>
<defaultSearchField>fulltext</defaultSearchField>

最佳答案

尝试使用 UAX29URLEmailTokenizerFactory tokenizer ,就像标准的标记器一样,但可以识别电子邮件地址、URL、域名和 IPv4/IPv6 地址。 Solr 引用指南中的示例:

:Visit http://accarol.com/contact.htm?from=external&a=10 or e-mail bob.cratchet@accarol.com
:Visit , http://accarol.com/contact.htm?from=external&a=10 , or , email , bob.cratchet@accarol.com

关于solr - solr 搜索结果中的网址和电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8728579/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com