0

如果我搜索"Movies 10"它会找到名称为Movies 10

如果我搜索Movies 10它不会返回任何文件。

以下是我的架构:

<?xml version="1.0" encoding="UTF-8" ?>
<schema name="entertainment" version="1.0">
    <types>
        <!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
        <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0"/>
        <fieldType name="uuid" class="solr.UUIDField" indexed="true"/>
        <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" />
                <!-- in this example, we will only use synonyms at query time
                 <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
                 -->
                <filter class="solr.LowerCaseFilterFactory"/>
            </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>
    </types>


    <fields>
        <field name="uid" type="uuid" indexed="true" stored="true" default="NEW" />
        <field name="type" type="string" indexed="true" stored="true" required="true" />
        <field name="name" type="string" indexed="true" stored="true" required="true" />
        <field name="description" type="string" indexed="true" stored="true" required="false" />       
        <dynamicField name="movie_*" type="string" indexed="true" stored="true" />
        <dynamicField name="movie_review_*" type="string" indexed="true" stored="true" />
        <dynamicField name="movie_trailer_*" type="string" indexed="true" stored="true" />
        <dynamicField name="theater_*" type="string" indexed="true" stored="true" />
    </fields>

    <!-- Field to use to determine and enforce document uniqueness. 
     Unless this field is marked with required="false", it will be a required field
     -->
    <uniqueKey>uid</uniqueKey>

    <!-- field for the QueryParser to use when an explicit fieldname is absent -->
    <defaultSearchField>name</defaultSearchField>
    <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
    <solrQueryParser defaultOperator="OR"/>
</schema>
4

2 回答 2

5

要获得这种搜索行为,您需要更改name要使用的 fieldTypetext_general以便对值进行标记。通过name当前定义为字符串 fieldType,只会返回完全匹配。

于 2012-10-17T20:37:34.690 回答
0

逐字搜索字符串,因为您的 text_general 映射到 solr.TextField 与 Tokeniser 更适合。

于 2013-04-19T09:31:39.973 回答