在Solr中 - 空间会影响相关性

时间:2013-10-03 07:02:36

标签: solr

我已使用字段fullName索引2个用户文档:

fullname=Matt Cain
fullName=Matt Harvey

当我搜索

fullName:Matt Harvey

术语Matt Cain得分较高,但如果我搜索

fullName:matt OR fullName:harvey
然后Matt Harvey先来了。

如何正确配置我的schema.xml,以便solr正确处理它而不会手动破坏查询?

这是我当前schema.xml的一些相关部分

<fields>
    <!-- general -->
    <field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
    <field name="type" type="text_general" indexed="true" stored="true" multiValued="false"/>
    <field name="name" type="text_general" indexed="true" stored="true" multiValued="false"/>
    <field name="_version_" type="long" indexed="true" stored="true"/>

    <field name="firstName" type="text_general" indexed="true" stored="true"/>
    <field name="lastName" type="text_general" indexed="true" stored="true"/>
    <field name="fullName" type="text_general" indexed="true" stored="true"/>
    <field name="email" type="text_general" indexed="true" stored="true"/>
    <field name="workPlace" type="text_general" indexed="true" stored="true"/>
    <field name="geoArea" type="text_general" indexed="true" stored="true"/>
    <field name="gender" type="text_general" indexed="true" stored="true"/>
    <field name="tags" type="text_general" indexed="true" stored="true" multiValued="true"/>
    <field name="birthDate" type="date" indexed="true" stored="true"/>
    <field name="followersCount" type="long" indexed="true" stored="true"/>
    <field name="featuredLevel" type="int" indexed="true" stored="true" multiValued="false"/>

    <field name="fbId" type="text_general" indexed="false" stored="true"/>
    <field name="imageUrl" type="text_general" indexed="false" stored="true"/>

    <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>

    <dynamicField name="*" type="ignored" multiValued="true"/>

</fields>

...

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="15"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.LowerCaseFilterFactory"/>
        </analyzer>
    </fieldType>

如果还有其他部分需要回答这个问题,我会很乐意发布。不想张贴整件事.. 感谢

1 个答案:

答案 0 :(得分:0)

fullName:Matt Harvey仅根据Lucene Syntax搜索fullName:Matt。要解决此问题,您需要搜索fullName:"Matt Harvey"