Solr:搜索结果不一致

时间:2013-03-25 11:11:10

标签: java solr solrj lucene

我在Solr中遇到特定关键字的搜索结果不一致。

行为:

例如关键字是“音乐”,并且包含3个包含此关键字的文档。

使用网址“http://abc.xyz.com:8983/solr/core3/select/?q=music”使用此关键字执行搜索,当我们再次点击它时会提供单个文档,它将返回所有三个索引文档。我们再次点击它将返回单个文档。这就是一致发生的不一致行为。

我无法想到造成这个问题的原因。

是Solr缓存吗?它与其他Solr配置有关吗?

Solr版本:3.6.1

solrconfig.xml的重要配置

<requestHandler name="/select" class="solr.SearchHandler">
    <lst name="defaults">
        <str name="echoParams">explicit</str>
        <int name="rows">50</int>
        <str name="df">keywords</str>
    </lst>
</requestHandler>
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
        <str name="config">db-data-config-xsl.xml</str>
    </lst>  
</requestHandler>

<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0"/>
<queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0"/>

schema.xml中

                                                            

        </analyzer>
    </fieldType>
    <fieldtype name="string"  class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
    <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
    <fieldType name="text" class="solr.TextField" positionIncrementGap="100">

        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English"/>
        </analyzer>
    </fieldType>
    <fieldType name="shingleString" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
        <analyzer type="index">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>

            <filter class="solr.PositionFilterFactory" />
        </analyzer>
    </fieldType>
    <fieldType name="facet_tex" class="solr.TextField" sortMissingLast="true" omitNorms="true">
        <analyzer>

            <tokenizer class="solr.KeywordTokenizerFactory"/>   
            <filter class="solr.LowerCaseFilterFactory" />
            <!-- The TrimFilter removes any leading or trailing whitespace -->
            <filter class="solr.TrimFilterFactory" />        
            <!--filter class="solr.PatternReplaceFilterFactory"  pattern="([^a-z])" replacement="" replace="all"   /-->
        </analyzer>
    </fieldType>

    <fieldType name="facet_comma" class="solr.TextField" sortMissingLast="true" omitNorms="true">
        <analyzer>
            <tokenizer class="solr.PatternTokenizerFactory" pattern=","/>

            <filter class="solr.LowerCaseFilterFactory" />
            <!-- The TrimFilter removes any leading or trailing whitespace -->
            <filter class="solr.TrimFilterFactory" />   
            <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>             
            <!--filter class="solr.PatternReplaceFilterFactory"  pattern="([^a-z])" replacement="" replace="all"   /-->
        </analyzer>
    </fieldType>

        <fieldType name="text_auto" class="solr.TextField">
            <analyzer>
                <tokenizer class="solr.PatternTokenizerFactory" pattern=","/>
                <filter class="solr.LowerCaseFilterFactory"/>
                <filter class="solr.TrimFilterFactory" />  
                <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="25" side="front" />
            </analyzer>
        </fieldType>


    <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"/>
        </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>
    <fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="," replacement=" "/>

            <tokenizer class="solr.WhitespaceTokenizerFactory"/>

            <filter class="solr.LowerCaseFilterFactory"/>

        </analyzer>
        <analyzer type="query">
            <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="," replacement=" "/>

            <tokenizer class="solr.WhitespaceTokenizerFactory"/>

            <filter class="solr.LowerCaseFilterFactory"/>

        </analyzer>
    </fieldType>
    <fieldType name="text_en_comma" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">

            <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="," replacement=" "/>

            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.TrimFilterFactory" />

            <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="lang/stopwords_en.txt"
            enablePositionIncrements="true" />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
            <filter class="solr.KeywordMarkerFilterFactory" 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="lang/stopwords_en.txt"
            enablePositionIncrements="true"                />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>

        </analyzer>
    </fieldType>

    <fieldType name="alphaOnlySort" class="solr.TextField" sortMissingLast="true" omitNorms="true">
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>

            <filter class="solr.LowerCaseFilterFactory" />

            <filter class="solr.TrimFilterFactory" />

            <filter class="solr.PatternReplaceFilterFactory"
            pattern="([^a-z])" replacement="" replace="all"/>
        </analyzer>
    </fieldType>
    <fieldType name="text_en_suggest" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
        <analyzer type="index">
            <tokenizer class="solr.PatternTokenizerFactory" pattern=","/>
            <filter class="solr.TrimFilterFactory" />
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="true" />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.PatternTokenizerFactory" pattern=","/>
            <filter class="solr.TrimFilterFactory" />
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_en.txt" enablePositionIncrements="true"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.EnglishPossessiveFilterFactory"/>
        </analyzer>
    </fieldType>
</types>

<fields>   

    <field name="section"     type="string"    indexed="true"  stored="true"  multiValued="false" /> 
    <field name="url"    type="string"    indexed="false"  stored="true"  multiValued="false" /> 
    <field name="title"    type="string"    indexed="true"  stored="true"  multiValued="false" /> 
    <field name="description"     type="string"    indexed="true"  stored="true"  multiValued="false" /> 
    <field name="keywords"     type="text_en_comma"    indexed="true"  stored="true"  multiValued="true" /> 
    <field name="category"    type="facet_comma"    indexed="true"  stored="true"  multiValued="false" />  
    <field name="robots"    type="string"    indexed="true"  stored="true"  multiValued="false" />  
    <field name="keywords_suggest"     type="text_en_suggest"    indexed="true"  stored="true"  multiValued="true" /> 

</fields>

<copyField source="keywords" dest="keywords_suggest"/>



<uniqueKey>title</uniqueKey>


<defaultSearchField>keywords</defaultSearchField>


<solrQueryParser defaultOperator="AND"/>

如果有人可以指导,我们将不胜感激。

谢谢, Bhavesh

1 个答案:

答案 0 :(得分:0)

检查您的参数timeAllowed,可以在solrconfix.xml中的某个处理程序中进行描述

还有问题:你的指数有多大?在docrconfix.xml和scheme.xml文件中查看文档是多么容易。