使用 Solr 1.4 进行通配符搜索和突出显示 [英] Wildcard searching and highlighting with Solr 1.4

查看:25
本文介绍了使用 Solr 1.4 进行通配符搜索和突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了一些小的配置和架构更改之外,我已经安装了 SOLR 1.4 的基本版本.

I've got a pretty much vanilla install of SOLR 1.4 apart from a few small config and schema changes.

<requestHandler name="standard" class="solr.SearchHandler" default="true">
    <!-- default values for query parameters -->
    <lst name="defaults">
        <str name="defType">dismax</str>
        <str name="echoParams">explicit</str>
        <str name="qf">
            text
        </str>
        <str name="spellcheck.dictionary">default</str>
        <str name="spellcheck.onlyMorePopular">false</str>
        <str name="spellcheck.extendedResults">false</str>
        <str name="spellcheck.count">1</str>
    </lst>
</requestHandler>

我用于索引的主要字段类型是:

The main field type I'm using for Indexing is this:

<fieldType name="textNoHTML" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <charFilter class="solr.HTMLStripCharFilterFactory" />
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <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="1"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <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="1"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
        </analyzer>
    </fieldType>

现在,当我使用

"q=search+term&hl=on"

我得到了突出显示,并且得到了准确的分数.

I get highlighting, and nice accurate scores.

但是,对于通配符,我假设您需要使用q.alt"?真的吗?如果是这样,我的查询如下所示:

BUT, for wildcard, I'm assuming you need to use "q.alt"? Is that true? If so my query looks like this:

"q.alt=search*&hl=on"

当我使用上面的查询时,突出显示不起作用,所有的分数都是1.0".

When I use the above query, highlighting doesn't work, and all the scores are "1.0".

我做错了什么?在不绕过一些非常酷的 SOLR 优化的情况下,这是我想要的.

What am I doing wrong? is what I want possible without bypassing some of the really cool SOLR optimizations.

干杯!

推荐答案

据我所知,您不能在 dismax 处理程序中使用通配符,请参阅 http://wiki.apache.org/solr/DisMaxRequestHandler#q.

From what I know you can't use wildcards with the dismax handler, see http://wiki.apache.org/solr/DisMaxRequestHandler#q.

为了模拟通配符搜索,我按照此处的一些说明使用了 EdgeNGrams:http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/.其实我真的只是在schema.xml中添加了edgytext fieldtype,并更改了我要搜索的字段的fieldtype.

To simulate wildcard searching I used EdgeNGrams following some of the instructions here: http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/. Actually I really only added the edgytext fieldtype to schema.xml and changed the fieldtype of the field I wanted to search.

希望这有帮助!

这篇关于使用 Solr 1.4 进行通配符搜索和突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆