solr默认查询*:*不起作用

时间:2012-03-29 11:50:00

标签: solr

我正在使用查询从solr的管理页面(4.0 SNAPSHOT)中检索所有结果。但它没有显示任何结果。我检查了其他查询,他们正在返回结果。那么为什么默认查询不起作用?

SolrConfig.xml文件

<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <luceneMatchVersion></luceneMatchVersion>
    <dataDir></dataDir>
  <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
  <indexDefaults>
   <!-- Values here affect all index writers and act as a default unless overridden. -->
    <useCompoundFile>false</useCompoundFile>
    <mergeFactor>10</mergeFactor>
    <ramBufferSizeMB>32</ramBufferSizeMB>
    <maxFieldLength>10000</maxFieldLength>
    <writeLockTimeout>1000</writeLockTimeout>
    <commitLockTimeout>10000</commitLockTimeout>
    <lockType>native</lockType>
  </indexDefaults>

  <mainIndex>
    <useCompoundFile>false</useCompoundFile>
    <ramBufferSizeMB>32</ramBufferSizeMB>
    <mergeFactor>10</mergeFactor>
    <unlockOnStartup>false</unlockOnStartup>
    <reopenReaders>true</reopenReaders>
    <deletionPolicy class="solr.SolrDeletionPolicy">
      <str name="maxCommitsToKeep">1</str>
      <str name="maxOptimizedCommitsToKeep">0</str>
    </deletionPolicy>
     <infoStream file="INFOSTREAM.txt">false</infoStream> 
  </mainIndex>

  <jmx />

  <updateHandler class="solr.DirectUpdateHandler2">
  </updateHandler>

  <query>
    <maxBooleanClauses>1024</maxBooleanClauses>
    <filterCache
      class="solr.FastLRUCache"
      size="512"
      initialSize="512"
      autowarmCount="0"/>

      <queryResultCache
      class="solr.LRUCache"
      size="1024"
      initialSize="1024"
      autowarmCount="0"/>

    <documentCache
      class="solr.LRUCache"
      size="1024"
      initialSize="1024"
      autowarmCount="0"/>

    <enableLazyFieldLoading>true</enableLazyFieldLoading>
    <queryResultWindowSize>50</queryResultWindowSize>
    <queryResultMaxDocsCached>200</queryResultMaxDocsCached>

    <listener event="newSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
        <lst> <str name="q">lockboxweb</str> <str name="start">0</str> <str name="rows">10</str> </lst>
        <lst> <str name="q">iskootonboarding</str> <str name="start">0</str> <str name="rows">10</str> </lst>
        <lst><str name="q">Mac</str></lst>
      </arr>
    </listener>

    <listener event="firstSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
        <lst> <str name="q">LinuxTools</str><str name="start">0</str><str name="rows">10</str></lst>
        <lst><str name="q">lookup</str></lst>
      </arr>
    </listener>

    <useColdSearcher>false</useColdSearcher>

    <maxWarmingSearchers>2</maxWarmingSearchers>

  </query>

  <!-- 
    Let the dispatch filter handler /select?qt=XXX
    handleSelect=true will use consistent error handling for /select and /update
    handleSelect=false will use solr1.1 style error formatting
    -->
  <requestDispatcher handleSelect="true" >
    <!--Make sure your system has some authentication before enabling remote streaming!  -->
    <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048000" />

    <!-- Set HTTP caching related parameters (for proxy caches and clients).

         To get the behaviour of Solr 1.2 (ie: no caching related headers)
         use the never304="true" option and do not specify a value for
         <cacheControl>
    -->
    <!-- <httpCaching never304="true"> -->
    <httpCaching lastModifiedFrom="openTime" etagSeed="Solr">
       <cacheControl>max-age=30, public</cacheControl>
    </httpCaching>
  </requestDispatcher>


  <requestHandler name="standard" class="solr.SearchHandler" >
     <lst name="defaults">
       <str name="echoParams">explicit</str>
     </lst>
  </requestHandler>

  <requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="master">
      <str name="replicateAfter">commit</str>
      <str name="replicateAfter">startup</str>
      <str name="confFiles">schema.xml,stopwords.txt</str>
    </lst>
</requestHandler>

  <requestHandler name="dismax" class="solr.SearchHandler" default="true">
    <lst name="defaults">
     <str name="defType">dismax</str>
     <str name="echoParams">explicit</str>
     <float name="tie">0.01</float>
     <!--
     <str name="qf">
        key^5.0 ng_key^4.0 description^1.5 sg_description^1.1 ng_description^1.0 ngs_description^1.0
     </str>
     -->
     <str name="qf">
        key^5.0 dl_key^4.0 ng_key^3.5 description^1.0 sg_description^1.0 ng_description^1.0 ngs_description^1.0
     </str>

     <str name="fl">
        key,description,url,source,durl,type
     </str>
     <str name="mm">
        2&lt;-1 5&lt;-2 6&lt;90%
     </str>
     <int name="ps">100</int>
     <str name="q.alt">*:*</str>
    </lst>
  </requestHandler>

  <!-- A component to return terms and document frequency of those terms. -->
  <searchComponent name="termsComponent" class="org.apache.solr.handler.component.TermsComponent"/>

  <requestHandler name="/terms" class="org.apache.solr.handler.component.SearchHandler">
     <lst name="defaults">
      <bool name="terms">true</bool>
    </lst>     
    <arr name="components">
      <str>termsComponent</str>
    </arr>
  </requestHandler>


  <!-- a search component that enables you to configure the top results for
       a given query regardless of the normal lucene scoring.-->
  <searchComponent name="elevator" class="solr.QueryElevationComponent" >
    <!-- pick a fieldType to analyze queries -->
    <str name="queryFieldType">string</str>
    <str name="config-file">elevate.xml</str>
  </searchComponent>

  <!-- a request handler utilizing the elevator component -->
  <requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="echoParams">explicit</str>
    </lst>
    <arr name="last-components">
      <str>elevator</str>
    </arr>
  </requestHandler>


  <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
  <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />
  <requestHandler name="/analysis/document" class="solr.DocumentAnalysisRequestHandler" />
  <requestHandler name="/analysis/field" class="solr.FieldAnalysisRequestHandler" />

  <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />

  <!-- ping/healthcheck -->
  <requestHandler name="/admin/ping" class="PingRequestHandler">
    <lst name="defaults">
      <str name="qt">standard</str>
      <str name="q">solrpingquery</str>
      <str name="echoParams">all</str>
    </lst>
  </requestHandler>

  <!-- Echo the request contents back to the client -->
  <requestHandler name="/debug/dump" class="solr.DumpRequestHandler" >
    <lst name="defaults">
     <str name="echoParams">explicit</str> <!-- for all params (including the default etc) use: 'all' -->
     <str name="echoHandler">true</str>
    </lst>
  </requestHandler>

  <admin>
    <defaultQuery>*:*</defaultQuery>
  </admin>

</config>

调试查询的输出

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">9</int>
  <lst name="params">
    <str name="explainOther"/>
    <str name="indent">on</str>
    <str name="hl.fl"/>
    <str name="wt"/>
    <str name="version">2.2</str>
    <str name="rows">10</str>
    <str name="fl">*,score</str>
    <str name="debugQuery">on</str>
    <str name="start">0</str>
    <str name="q">*:*</str>
    <str name="qt"/>
    <str name="fq"/>
  </lst>
</lst>
<result name="response" numFound="0" start="0" maxScore="0.0">
</result>
<lst name="debug">
  <str name="rawquerystring">*:*</str>
  <str name="querystring">*:*</str>
  <str name="parsedquery">(+DisjunctionMaxQuery((ng_description:*:* | ng_key:*:*^3.5 | dl_key:*:*^4.0 | description:*:* | ngs_description:*:* | key:*:*^5.0)~0.01) ())/no_coord</str>
  <str name="parsedquery_toString">+(ng_description:*:* | ng_key:*:*^3.5 | dl_key:*:*^4.0 | description:*:* | ngs_description:*:* | key:*:*^5.0)~0.01 ()</str>
  <lst name="explain"/>
  <str name="QParser">DisMaxQParser</str>
  <null name="altquerystring"/>
  <null name="boostfuncs"/>
  <lst name="timing">
    <double name="time">8.0</double>
    <lst name="prepare">
      <double name="time">4.0</double>
      <lst name="org.apache.solr.handler.component.QueryComponent">
        <double name="time">3.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.FacetComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.HighlightComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.StatsComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.DebugComponent">
        <double name="time">0.0</double>
      </lst>
    </lst>
    <lst name="process">
      <double name="time">4.0</double>
      <lst name="org.apache.solr.handler.component.QueryComponent">
        <double name="time">2.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.FacetComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.MoreLikeThisComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.HighlightComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.StatsComponent">
        <double name="time">0.0</double>
      </lst>
      <lst name="org.apache.solr.handler.component.DebugComponent">
        <double name="time">2.0</double>
      </lst>
    </lst>
  </lst>
</lst>
</response>

1 个答案:

答案 0 :(得分:4)

您的solrconfig.xml将DisMax查询解析器列为默认值。它无法处理字段:值查询,因此*:*也不起作用。但是,q.alt参数在未指定q参数时使用标准解析器。有关详细信息,请参阅http://lucidworks.lucidimagination.com/display/solr/The+DisMax+Query+Parser